From 6d2e5d114118e594168f65c83732e8a470c0529f Mon Sep 17 00:00:00 2001 From: Pavlo Aksonov Date: Sat, 26 Mar 2016 09:52:37 +0100 Subject: [PATCH] avoid scene modificaiton for cloned scenes --- package.json | 2 +- src/Reducer.js | 14 +++----------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 2d5c75b69..5cced6168 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/Reducer.js b/src/Reducer.js index 1cf2ab68b..369d46915 100644 --- a/src/Reducer.js +++ b/src/Reducer.js @@ -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)]}; @@ -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 { @@ -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: