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

Prop/State change of Parent is causing child components to Re-mount #2886

Closed
KunwarSingh opened this issue Feb 16, 2018 · 6 comments
Closed

Comments

@KunwarSingh
Copy link

KunwarSingh commented Feb 16, 2018

Version

Tell us which versions you are using:

  • react-native-router-flux v4.0.0-beta.27
  • react-native v0.53.0

Code

Parent

`
render () {


<Scene
key="Child1"
component={Child1}

                <Scene
                    key="Child2"
                    component={Child2}
                </Scene>
            </Scene>
          </Router>
    }

`

Expected behaviour

on prop/state change of parent component which is connected to redux, only parent component should re-render, and also those child components which have same redux state connected.

Actual behaviour

on state/prop change in parent, Its re-mounting the child component, which triggers re-render, componentDidMount again for child

Assumption

I believe issue is in the way u initialize Router and Scenes, I didn't had any issue in earlier version

@KunwarSingh
Copy link
Author

For now I have resolved this by returning false from shouldComponentUpdate in Parent. I think its not feasible to re-render the component where u declared Router

@KunwarSingh
Copy link
Author

Still issue is there now Parent Component where Router is defined doesn't re-renders, but some the active scene does following on redux state change which is connected to parent component

WillMount
Render
WillUnmount
DidMount

@Blapi
Copy link
Collaborator

Blapi commented Feb 19, 2018

First, you should have a Stack/Scene with the key 'root' as a Parent.

Second, why are you doing this ?

@Blapi
Copy link
Collaborator

Blapi commented Aug 1, 2018

@KunwarSingh status there?

@aksonov
Copy link
Owner

aksonov commented Aug 8, 2018

Please try to reproduce it with Example project and latest version 4.0.0-beta.40. Feel free to open if the issue still exists

Closed due inactivity

@aksonov aksonov closed this as completed Aug 8, 2018
@aksonov
Copy link
Owner

aksonov commented Aug 8, 2018

@Blapi Feel free to close inactive tickets, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants