jlyman / RN-NavigationExperimental-Redux-Example

A small demonstration app showing how to use Redux to manage navigation state in a React Native (>0.21) application using NavigationExperimental
MIT License
342 stars 32 forks source link

RenderScene called twice #31

Open yeswanth opened 7 years ago

yeswanth commented 7 years ago

I placed a console.log in renderScene method in AppContainer.js (and did not modify any of the other code). For every page that is added to the navigation, the method is called twice. Is it a bug? How do I avoid renderScene method to be called second time?

 _renderScene({scene}) {
        // Here renderscene is printed twice for every route 
        console.log('renderscene');
        const { route } = scene

        switch(route.key) {
        case 'First':
            return <First />
        case 'Second':
            return <Second />
        case 'Third':
            return <Third />
        case 'Modal':
            return <Modal />
        }
    }

I'm facing similar issue with pure RN NavigationExperimental implementation in my own project.

jlyman commented 7 years ago

That's a good question, I'm not quite sure on that one. It looks like it pauses a bit between renders, which makes me wonder if there is a state change that is occurring with NavigationTransitioner after the animation completes that is causing a rerender.

Haven't had a chance to look into it too much, but anyone else seeing this or know more about it?

symmetriccurve commented 7 years ago

Looks like under the debug mode, the transition is bit late and triggering the _renderScene() twice before the first trigger is executed. It is not occurring while debug mode is off.