Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best Practice Using Router/Scene/Modal (Not an issue) #3051

Closed
alittletf opened this issue May 24, 2018 · 2 comments
Closed

Best Practice Using Router/Scene/Modal (Not an issue) #3051

alittletf opened this issue May 24, 2018 · 2 comments

Comments

@alittletf
Copy link

Version

Tell us which versions you are using:

  • react-native-router-flux v4.0.0-beta.28
  • react-native v0.54.4

I am curious what the best practices were around how to structure your Router.js file. Currently, I have every single Scene in my Router.js file and all the the Scenes are nested in one Router tag. Some scenes are nested inside other Scenes.

Is this common best practice?

I started looking into using a Modal tag since I wanted to load up a specific screen from the bottom up and in the documentation it told me to wrap my root Scene which contains all my other Scenes in the modal tag. I not only could not get it to work but I also dont want every single screen to animate in from bottom up.

It started to make me wonder if I am not using Scenes in my Router file correctly.

Thoughts?

@Blapi
Copy link
Collaborator

Blapi commented May 24, 2018

What I am doing on my end is :

        <Router
          backAndroidHandler={this.onBackPress}
          createReducer={reducerCreate}>
          <Stack
            key='root'
            hideNavBar
            transitionConfig={() => ({
              screenInterpolator: (props) => {
                const { scene, scenes } = props
                switch (scene.route.routeName) {
                  case 'myScene':
                    return theTransitionIWant
                  default:
                    return defaultTransition
                }
              }
            })}>
            <Scene
              key='myKey'
              component={myComponent}
              initial />
// all my other scenes
          </Stack>
        </Router>

As I'm not using the Tab, Drawer or Modal, I don't need to use nested scenes, I just put them all inside of my Stack :)

@aksonov
Copy link
Owner

aksonov commented Jun 6, 2018

@alittletf You may check also Example project as well as starter pack https://github.com/aksonov/react-native-starter-app

Basically good practice is to put everything in one place to see whole app logic.

@aksonov aksonov closed this as completed Jun 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants