Add sub-reducer support to NavigationStackReducer

Summary: Revise APIs of reducers, and ensure the stack reducer can support sub-reducers

Reviewed By: javache

Differential Revision: D2959915

fb-gh-sync-id: 20b28b9ead7ace3373489a806486999048d32aef
shipit-source-id: 20b28b9ead7ace3373489a806486999048d32aef
This commit is contained in:
Eric Vicenti
2016-02-22 16:15:42 -08:00
committed by facebook-github-bot-6
parent 876ecb291f
commit dcb68db758
10 changed files with 253 additions and 369 deletions

View File

@@ -29,11 +29,20 @@ var {
} = NavigationExperimental;
const NavigationBasicReducer = NavigationReducer.StackReducer({
initialStates: [
{key: 'First Route'}
],
matchAction: action => action.type === 'push',
actionStateMap: action => ({key: action.key}),
getPushedReducerForAction: (action) => {
if (action.type === 'push') {
return (state) => state || {key: action.key};
}
return null;
},
getReducerForState: (initialState) => (state) => state || initialState,
initialState: {
key: 'AnimatedExampleStackKey',
index: 0,
children: [
{key: 'First Route'},
],
},
});
class NavigationAnimatedExample extends React.Component {