【问题标题】:Reset scene navigation in react-native-router-flux在 react-native-router-flux 中重置场景导航
【发布时间】:2016-10-23 14:20:52
【问题描述】:

我在使用 react-native-router-flux 时遇到了一些问题。我的路由器是这样的:

    ...
        <Scene type={ActionConst.RESET} key="tabs"
               tabs={true}>
                        <Scene
                          key="explore"
                          initial
                          component={Explore}
                       />

                        <Scene key="createPost">
                          <Scene
                            key="camera"
                            type="reset"
                            component={Camera}
                          />
                          <Scene
                            key="compose"
                            component={Compose}
                          />
                          <Scene
                            key="finish"
                            component={Finish}
                          />
                        </Scene>
                        <Scene
                          key="profile"
                          component={Profile}
                        />
 </Scene> 
...

当我单击选项卡中的 createPost 图标并按照以下流程进行操作时,问题就出现了:相机 -> 撰写 -> 完成。完成该过程后,我应该上传数据并进行探索,一切正常,但是如果我尝试创建新帖子,则会将我直接重定向到“完成”场景。

所以直到现在,当我完成我尝试过的过程时:

Actions.explore({type: 'reset'})

//

Actions.callback({ key: 'tabs', type: 'reset'}); Actions.explore()

//

Actions.callback({ key: 'createStory', type: 'reset'}); Actions.explore()

但任何事情都按预期工作。有人可以帮我解决这个问题吗?

谢谢!

更新

好吧,我找到了一个“可能的”解决方案:

Actions.popTo('capture'); -> 这将回到 createPost 中的第一个场景

Actions.explore(); -> 退出 createPost。

我想还有另一种方法可以做到...

【问题讨论】:

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


    【解决方案1】:

    您可以尝试在 createPost 场景中添加 type=reset 吗?

    <Scene key="createPost" type="reset">
    

    【讨论】:

    • 不工作。如果我这样做有几个问题: 1. 如果我这样做:选项卡 -> createPost ->(返回)选项卡 -> 错误:找不到带有 key=explore 的路由(当我使用 Actions.explore() 时)或者如果如果我尝试返回,我使用 Actions.pop() 没有场景变化。 2. 如果我完成我的过程并返回场景探索并尝试再次打开 createPost,则应用程序会中断。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-01-05
    • 2019-03-12
    • 1970-01-01
    • 2016-12-22
    • 2017-08-19
    • 2017-04-20
    • 1970-01-01
    相关资源
    最近更新 更多