This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useState, useReducer } from 'react'; | |
import { isEmpty, isNil } from 'ramda'; | |
const isObjectLiked = (value) => | |
value.constructor.name == "Array" || | |
value.constructor.name == "Object"; | |
const rehydrate = (value, defaultValue) => { | |
if (!value) return defaultValue; | |
if (value === 'false') str = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component, createContext } from "react" | |
import { differenceBy } from "lodash/fp" | |
const { Provider, Consumer: MultiSelectConsumer } = createContext({}) | |
export function toggleItemUpdater(item) { | |
return ({ items: currentStateItems }) => { | |
const hasItem = currentStateItems.some(it => it.id === item.id) | |
if (hasItem) { | |
return { items: currentStateItems.filter(it => it.id !== item.id) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//change Screen.js in node modules react-native-navigation | |
/*eslint-disable*/ | |
import React, {Component} from 'react'; | |
import { | |
NativeAppEventEmitter, | |
DeviceEventEmitter, | |
Platform | |
} from 'react-native'; | |
import platformSpecific from './deprecated/platformSpecificDeprecated'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component, createContext } from 'react'; | |
const context = createContext({ | |
activeTabId: '', | |
changeTab: () => {} | |
}); | |
const { Provider, Consumer } = context; | |
const Tab = ({ id, children }) => ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { createContext, Component } from "react"; | |
import { Auth } from "aws-amplify"; | |
const AuthContext = createContext({ | |
isAuthenticated: false, | |
isAuthenticating: true | |
}); | |
class AuthProvider extends Component { | |
state = { | |
isAuthenticated: false, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Below I am using react's context api to create a modular way to manage modals within an application | |
// Context Environment | |
import React, { Component, createContext } from 'react' | |
const ModalContext = createContext({ | |
component: null, | |
props: {}, | |
showModal: () => {}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import PropTypes from 'prop-types'; | |
import { Animated, Easing } from 'react-native' | |
class SlideIn extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
height: new Animated.Value(0), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyForm extends Component { | |
render() { | |
let { formData, onSubmitForm } = this.props; | |
return ( | |
<View> | |
<TextInput value={formData.name} /> | |
<TextInput value={formData.email} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const createContext = value => { | |
const context = reactCreateContext(value); | |
export const withContext = Component => { | |
const C = props => ( | |
<context.Consumer> | |
{context => <Component {...context} {...props} />} | |
</context.Consumer> | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Buttons = branch( | |
props => props.loading, | |
withProps({ label: 'LOADING...', isDisabled: true }), | |
withProps({ id: 'signIn', label: 'SIGN IN', type: 'submit' }) | |
)(SignInButton); | |
const Buttons = ({ loading }) => | |
loading ? ( | |
<SignInButton label="LOADING..." isDisabled={true} /> | |
) : ( |
NewerOlder