diff --git a/Example/components/TabView.js b/Example/components/TabView.js index a3c65b46d..af0a87579 100644 --- a/Example/components/TabView.js +++ b/Example/components/TabView.js @@ -9,7 +9,7 @@ var Actions = require('react-native-router-flux').Actions; class TabView extends React.Component { render(){ return ( - + Tab {this.props.title} {this.props.name === "tab1_1" && diff --git a/Example/package.json b/Example/package.json index d60d6b9b3..8c3ea53fa 100644 --- a/Example/package.json +++ b/Example/package.json @@ -9,7 +9,7 @@ "react-native": "^0.22.0", "react-native-button": "^1.2.1", "react": "^0.14.7", - "react-native-router-flux": "^3.1.1", + "react-native-router-flux": "^3.1.4", "react-native-modalbox": "^1.3.0" } } diff --git a/package.json b/package.json index 5da2c8b06..08e3e43f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-router-flux", - "version": "3.1.3", + "version": "3.1.4", "description": "React Native Router using Flux architecture", "repository": { "type": "git", diff --git a/src/DefaultRenderer.js b/src/DefaultRenderer.js index 52d751229..b63746f00 100644 --- a/src/DefaultRenderer.js +++ b/src/DefaultRenderer.js @@ -57,8 +57,7 @@ export default class DefaultRenderer extends Component { } _renderHeader(/*NavigationSceneRendererProps*/ props) { - const NavigationBar = props.navigationState.navBar || NavBar; - return state.title} />; diff --git a/src/Reducer.js b/src/Reducer.js index 0ca61bd8b..7afcc9f79 100644 --- a/src/Reducer.js +++ b/src/Reducer.js @@ -45,7 +45,7 @@ function update(state,action){ // clone state, TODO: clone effectively? if (!state.scenes[action.key] && action.key.indexOf('_')!=-1){ action.key = action.key.substring(action.key.indexOf('_')+1); - console.log("Transform to key="+action.key); + //console.log("Transform to key="+action.key); } const newProps = {...state.scenes[action.key], ...action}; let newState = Immutable.fromJS(state).toJS(); @@ -124,7 +124,7 @@ function reducer({initialState, scenes}){ assert(scenes, "scenes should not be null"); assert(scenes.current, "scenes.current should not be null"); return function(state, action){ - console.log("ACTION:", action); + //console.log("ACTION:", action); state = state || {...initialState, scenes}; //console.log("ACTION:", action); //console.log("STATE:", JSON.stringify(state)); diff --git a/src/Router.js b/src/Router.js index 6a835cde8..b41e3bc36 100644 --- a/src/Router.js +++ b/src/Router.js @@ -29,7 +29,8 @@ export default class extends Component { _handleProps(props){ const scenesMap = props.scenes || Actions.create(props.children); const {children, style, scenes, reducer,...parentProps} = props; - const initialState = getInitialState(scenesMap, parentProps); + scenesMap.rootProps = parentProps; + const initialState = getInitialState(scenesMap); this.setState({reducer: props.reducer || Reducer({initialState, scenes:scenesMap})}); } @@ -46,14 +47,7 @@ export default class extends Component { return null; } Actions.callback = props=>onNavigate(props); - const Component = navigationState.component || DefaultRenderer; - const props = navigationState.scenes[navigationState.scenes.current]; - - return ( - - ); + return ; } render(){ diff --git a/src/State.js b/src/State.js index 0da0d83ab..7eeee071b 100644 --- a/src/State.js +++ b/src/State.js @@ -11,7 +11,7 @@ import assert from 'assert'; export function getInitialState(route:{string: any},scenes:{string:any}, position=0, props={}){ const {key, style, type, ...parentProps} = props; if (!route.children){ - return {...route, sceneKey:route.key, key:position+'_'+route.key, ...parentProps}; + return { ...scenes.rootProps, ...route, sceneKey:route.key, key:position+'_'+route.key, ...parentProps,}; } let {children, ...res} = {...route, ...parentProps}; let index = 0; @@ -35,7 +35,7 @@ export default function(scenes:{string: any}, props){ // find 'root' component and get state from it for (let route in scenes){ if (scenes.hasOwnProperty(route) && !scenes[route].parent){ - return getInitialState(scenes[route], scenes, 0, props); + return getInitialState(scenes[route], scenes); } } }