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

Same route on the stack more than once #30

Closed
martinbooth opened this Issue Aug 1, 2017 · 5 comments

Comments

Projects
None yet
3 participants
@martinbooth
Copy link

martinbooth commented Aug 1, 2017

https://github.com/LeoLeBras/react-router-navigation/blob/master/modules/DefaultRenderer.js#L54 seems to assume that routeName would be unique amongst all the scenes, but it doesn't have to be. In the event it's not unique, the wrong scene is rendered

@LeoLeBras

This comment has been minimized.

Copy link
Member

LeoLeBras commented Sep 24, 2017

Hi @martinbooth Do you have an example that reproduces the issue?

@LeoLeBras LeoLeBras added the bug 🙃 label Sep 24, 2017

@LeoLeBras LeoLeBras added this to the 1.0.0-rc milestone Sep 24, 2017

@LeoLeBras LeoLeBras self-assigned this Sep 24, 2017

@allenhsu

This comment has been minimized.

Copy link

allenhsu commented Nov 24, 2017

In my project, this is causing bugs in transition animation.

For example, there's a card for topic page:

<Card exact path='/topics/:topic_id' component={Topic} />

If you push a topic from a non-topic page, it's fine. But if you push a topic from another topic page, when the push begins, the first topic page will be rendered as the second one, and when popping, the first topic will remain as the second one until the second one unmount.

Because for the topic card, the route name is actually the path /topics/:topic_id, so the route name are same for both topic scenes. Then when searching for scene with route name, it always return the last matched one.

@allenhsu

This comment has been minimized.

Copy link

allenhsu commented Nov 24, 2017

But seems it's actually caused by how react-navigation looks for components, it only passes routeName to the router, I don't think it can be fixed in react-router-navigation unless reimplement the entire CardStack.

https://github.com/react-community/react-navigation/blob/master/src/views/CardStack/CardStack.js#L431

@allenhsu

This comment has been minimized.

Copy link

allenhsu commented Nov 24, 2017

I tried and double checked the code of react-navigation, this bug does not exist in react-navigation, because the default implementation is not caching scenes. Instead, it looks for the component, and wrap it into a SceneView which extends PureComponent then return. So different scenes with same routeName are always different components. Caching and optimization is done by PureComponent. Maybe we can do the same in react-router-navigation?

@LeoLeBras LeoLeBras referenced this issue Dec 9, 2017

Closed

V1 Roadmap #56

18 of 18 tasks complete

@LeoLeBras LeoLeBras modified the milestones: 1.0.0-rc, 1.0.0-stable Dec 9, 2017

@LeoLeBras LeoLeBras added the v1 stable label Dec 9, 2017

@LeoLeBras LeoLeBras removed this from the v1.0.0-stable milestone Mar 10, 2018

@LeoLeBras

This comment has been minimized.

Copy link
Member

LeoLeBras commented Oct 1, 2018

This should be corrected with the recent changes made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment