Skip to content

Commit

Permalink
fix for #364
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavlo Aksonov committed Mar 22, 2016
1 parent 3fba076 commit 890a005
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Example/components/TabView.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var Actions = require('react-native-router-flux').Actions;
class TabView extends React.Component {
render(){
return (
<View style={styles.container}>
<View style={[styles.container, this.props.sceneStyle]}>
<Text>Tab {this.props.title}</Text>
{this.props.name === "tab1_1" &&
<Button onPress={Actions.tab1_2}>next screen for tab1_1</Button>
Expand Down
2 changes: 1 addition & 1 deletion Example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
3 changes: 1 addition & 2 deletions src/DefaultRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ export default class DefaultRenderer extends Component {
}

_renderHeader(/*NavigationSceneRendererProps*/ props) {
const NavigationBar = props.navigationState.navBar || NavBar;
return <NavigationBar
return <NavBar
{...props}
getTitle={state => state.title}
/>;
Expand Down
4 changes: 2 additions & 2 deletions src/Reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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));
Expand Down
12 changes: 3 additions & 9 deletions src/Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})});
}

Expand All @@ -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 (
<Component
navigationState={navigationState}
onNavigate={onNavigate} data={props}/>
);
return <DefaultRenderer navigationState={navigationState}/>;
}

render(){
Expand Down
4 changes: 2 additions & 2 deletions src/State.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}
}

0 comments on commit 890a005

Please sign in to comment.