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 { createTransform, getStoredState, purgeStoredState } from 'redux-persist' | |
import { autoRehydrate as baseAutoRehydrate, createPersistor as baseCreatePersistor, persistStore as basePersistStore } | |
export { createTransform, getStoredState, purgeStoredState } | |
import immutableConfig from './immutableConfig' // basically verbatim redux-persist-immutable-state but keys renamed: _stateInit, _stateGetter, ... | |
import stateReconciler from './stateReconciler' | |
// perhaps we should add some validation to make sure stateReconciler is not being overriden? | |
export const autoRehydrate = (config, ...args) => { |
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 {getStoredState, createPersistor, autoRehydrate } from 'redux-persist' | |
export async function bootstrap () { | |
let initialState | |
try { | |
initialState = await getStoredState() | |
} catch (err) { | |
initialState = {} | |
} |
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, { | |
Animated, | |
Component, | |
PropTypes, | |
} from 'react-native' | |
import _ from 'lodash' | |
import config from '../config' | |
class Animation extends Component { |
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
// navbar can be imperatively set / overrode via context | |
// this is a little automagical, but also allows for unlimited flexibility including changing route title within one route (e.g. intentBuilder) | |
class SomeScene extends Component { | |
componentWillMount() { | |
this.context.navbar.set({ | |
left, | |
middle, | |
right, | |
//... |
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 stringify from 'json-stringify-safe' | |
// use a special rehydrating reducer | |
const rehydratingReducer = (state, action) => { | |
if (action.type === 'REHYDRATE') return action.payload | |
else return reducer(state, action) | |
} | |
// subscribe to store and serialize safely | |
// should either debounce or selectively run this method as it is expensive |
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
<DrawerIOS | |
disabled={!!this.props.modalValues.hasModals} | |
ref="drawer" | |
type="static" | |
content={sidebarContent} | |
onOpen={() => this.setState({isDrawerOpened: true})} | |
onClose={() => this.setState({isDrawerOpened: false})} | |
onOpenStart={() => { | |
this._hideKeyboard(); | |
this._setStatusBarHidden(true); |
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
try { | |
let data = await getSomeData() | |
processData(data) | |
// ... do more stuff | |
} catch (err) { | |
// handle bad data or exception | |
} |
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, | |
View, | |
Text, | |
TouchableOpacity, | |
StyleSheet , | |
} from 'react-native' |
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 default class App extends Component { | |
state = {initialized: false} | |
componentWillMount () { | |
persistStore(store, config, () => { | |
this.setState({initialized: true}) | |
}) | |
} | |