Skip to content

Instantly share code, notes, and snippets.

@dabit3
Last active December 8, 2016 22:00
Show Gist options
  • Save dabit3/2f509823f0ad29e0a4f1480cd9f0fd7a to your computer and use it in GitHub Desktop.
Save dabit3/2f509823f0ad29e0a4f1480cd9f0fd7a to your computer and use it in GitHub Desktop.
Navigation Card Stack implementation with Redux - navReducer
import { NavigationExperimental } from 'react-native'
const {
StateUtils: NavigationStateUtils
} = NavigationExperimental
import { PUSH_ROUTE, POP_ROUTE } from './constants'
function navReducer(state, action) {
if (!state) {
return {
index: 0,
routes: [{ key: 'Home' }],
}
}
switch (action.type) {
case PUSH_ROUTE: {
return NavigationStateUtils.push(state, action.route)
}
case POP_ROUTE: {
return NavigationStateUtils.pop(state)
}
default:
return state
}
}
export default navReducer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment