Search code examples
react-nativereact-native-router-flux

Infinite back functionality like Instagram


Lets suppose, in an app there is ViewProfile Component, we open this Component and we see list of users who like this opened profile. We click one AnotherUser34 (With same ViewProfile Component) and see his profile and users who like him, and again we click/open 91AnotherUser from there, and we open 10 more profiles and so on. How to achive back functionality for each this? When I press back on ViewProfile Component, it goes back to Tabbar Component. I want it to go back similar way components are opened.

I want to have Instagram like back functionality.

Please suggest, a small hint will do the job, Thanks.

Below is my the Scene structure ( Specifically : https://github.com/bartonhammond/snowflake/blob/master/src/snowflake.js )

<Router>
<Scene  key='root' hideNavBar>
<Scene key='login'/>
<Scene key='register'/>
<Scene key='Tabbar'>
    <Scene key='Main'>
        <Scene key='ViewProfile'/>
    </Scene>
    <Scene key='Nav2'/>
    <Scene key='NavMenu3'/>
    <Scene key='NavMenu4'/>
</Scene>
</Router>

Solution

  • It is exact use case for 'clone' scenes.

    From https://github.com/aksonov/react-native-router-flux/blob/master/docs/API.md:

    Scenes marked with clone will be treated as templates and cloned into the current scene's parent when pushed. See example.