【问题标题】:Is there a way to get the scene history from react-native-router-flux?有没有办法从 react-native-router-flux 获取场景历史?
【发布时间】:2017-07-04 07:34:38
【问题描述】:

我有一种情况,我需要将当前场景与调用 Actions.pop() 时用户返回的场景进行比较;

基本上,如果在某些场景之间转换,我需要触发一堆动作来为用户返回的场景设置商店状态。发生这种情况是因为我有一些使用相同组件的路线,因此在弹出当前场景后,商店仍然反映旧场景。

react-native-router-flux 中有没有办法获取场景历史记录?

我想在我的导航减速器中添加一些东西,但我希望 react-native-router-flux 已经为此提供了一些东西......它必须知道它会弹出什么,不是吗?

【问题讨论】:

    标签: react-native react-native-router-flux


    【解决方案1】:

    有了 v4,你现在就可以做到了:

    const reducerCreate = (params) => {
      const defaultReducer = new Reducer(params) // import from RNRF
      return (state, action) => {
        console.log('Action :', action)
        console.log('State :', state)
        return defaultReducer(state, action)
      }
    }
    

    然后在你的路由器中

    <Router
      createReducer={reducerCreate}>
    

    【讨论】:

      猜你喜欢
      • 2017-05-10
      • 1970-01-01
      • 1970-01-01
      • 2017-01-05
      • 2017-08-19
      • 2018-01-18
      • 2017-04-20
      • 2017-12-23
      • 1970-01-01
      相关资源
      最近更新 更多