Skip to content

Commit

Permalink
avoid scene modificaiton for cloned scenes
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavlo Aksonov committed Mar 26, 2016
1 parent fee8981 commit 6d2e5d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
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.2.2",
"version": "3.2.3",
"description": "React Native Router using Flux architecture",
"repository": {
"type": "git",
Expand Down
14 changes: 3 additions & 11 deletions src/Reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function inject(state, action, props, scenes) {
props.key = state.key;
return {...state, ...props};
case PUSH_ACTION:
if (state.children[state.index].sceneKey == action.key){
if (state.children[state.index].sceneKey == action.key && !props.clone){
return state;
}
return {...state, index:state.index+1, children:[...state.children, getInitialState(props, scenes, state.index + 1, action)]};
Expand Down Expand Up @@ -116,11 +116,8 @@ function reducer({initialState, scenes}){
assert(scene, "missed route data for key="+action.key);

// clone scene
if (action.type === PUSH_ACTION && scene.clone) {
let uniqKey = `${_uniqPush++}$${scene.key}`;
let clone = {...scene, key: uniqKey, sceneKey: uniqKey, parent: getCurrent(state).parent};
state.scenes[uniqKey] = clone;
action.key = uniqKey;
if (scene.clone) {
action.parent = getCurrent(state).parent;
}

} else {
Expand All @@ -141,11 +138,6 @@ function reducer({initialState, scenes}){
action.parent = el.sceneKey;
}

// remove if clone
if (action.clone && action.sceneKey && (action.type === POP_ACTION || action.type === POP_ACTION2)) {
delete state.scenes[action.sceneKey];
}

}
switch (action.type) {
case POP_ACTION2:
Expand Down

0 comments on commit 6d2e5d1

Please sign in to comment.