Skip to content

Commit

Permalink
Restore 0.35 JUMP handling
Browse files Browse the repository at this point in the history
  • Loading branch information
wrozka committed Oct 20, 2016
1 parent 5a18d36 commit e944fbf
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/Reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,20 +210,8 @@ function inject(state, action, props, scenes) {
};
case ActionConst.JUMP: {
assert(state.tabs, `Parent=${state.key} is not tab bar, jump action is not valid`);
/* TODO: recursive key search (for sub-tab scenes)*/
ind = state.children.findIndex(el => el.sceneKey === action.key);
// variant #1
// get target scene with data passed in Actions.SCENE_KEY(PARAMS)
const targetSceneWithData = getInitialState(props, scenes, ind, action);
// find same scene in state.children
const targetSceneInState = state.children[ind];
// update child scene from state.children with pased data
state.children[ind] = { ...targetSceneInState, ...targetSceneWithData };

// variant #2 - NOT WORKING
// just update target scene in state tree with PARAMS
// state.children[ind] = { ...props, ...state.children[ind] };

ind = -1;
state.children.forEach((c, i) => { if (c.sceneKey === action.key) { ind = i; } });
assert(ind !== -1, `Cannot find route with key=${action.key} for parent=${state.key}`);

if (action.unmountScenes) {
Expand Down

3 comments on commit e944fbf

@masterkrang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wrozka @aksonov confirm this fixes frozen ScrollView for me

@wuxushun
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@czl1378
Copy link

@czl1378 czl1378 commented on e944fbf Nov 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR! But found that when I use this with Redux, the scene cannot change.

Here is my reducer:

import { ActionConst } from 'react-native-router-flux'

const initialState = {
  scene: {}
}

export default (state = initialState, action = {}) => {
  switch (action.type) {
    case ActionConst.FOCUS:
      return {
        ...state,
        scene: action.scene
      }
    default:
      return state
  }
}

Please sign in to comment.