Skip to content
This repository has been archived by the owner on Sep 29, 2022. It is now read-only.

All routes rendered twice #23

Closed
pjdevries opened this issue Mar 23, 2015 · 8 comments
Closed

All routes rendered twice #23

pjdevries opened this issue Mar 23, 2015 · 8 comments

Comments

@pjdevries
Copy link

Hi Larry,

Thanks for react-mini-router. I'm quite new to JavaScript, React and react-mini-router, so I apologize beforehand for asking for the obvious or being rather clumsy in my explanations :)

It seems that react-mini-router renders all my routes twice, each time I click one of my menu links. Can you give me any clues why that might happen and how it can be avoided?

Regards,

Pieter-Jan de Vries

@larrymyers
Copy link
Owner

Can you provide any code in your project where you think the issue is?

If you are seeing routes rendering multiple times for a single action, it likely means that you have DOM event that isn't being trapped and is propagating beyond the scope of the RouterMixin.

Check out the example app in react-mini-router. It's a functional React application, maybe that can give you some code you can use.

@pjdevries
Copy link
Author

Thanx for the swift response.

Not sure which code I can provide, since I don't know where the issue is :)

What I can see, is that the router executes setState() twice: first in handleClick() and a second time in onPopState(). It only happens when navigating from one route to another. If I click the active menu item, only handleClick() is executed. Does that help?

@larrymyers
Copy link
Owner

It shouldn't be calling popState and handleClick in the same render cycle. If this is happening it means something your application is triggering navigation beyond just the href in the anchor tag.

@pjdevries
Copy link
Author

I suppose popState and handleClick are called under different circumstances. Can you give me a clue under which circumstances? It might make it easier for me to pinpoint the problem.

@pjdevries
Copy link
Author

I accidentally closed the topic, so this comment is just to reopen it :)

@pjdevries pjdevries reopened this Mar 24, 2015
@pjdevries
Copy link
Author

Hey Larry,

Have you given my last question any thought?

I have a new question: if my app is not always in the web root (different for development and productrion), how do I configure the router and the url's in my links, so that they always get routed correctly?

Thanks in advance.

Kind regards,

Pieter-Jan de Vries

@larrymyers
Copy link
Owner

See the docs about configuring the router to mount at a specific path as the root path:

https://github.com/larrymyers/react-mini-router#configuration

@pjdevries
Copy link
Author

Thanks for the swift reply.
I would not dare asking any questions, if I wouldn't at least have read the documentation more than once. Either I'm not smart enough and miss the necessary experience and background knowledge (the most obvious reason) or the documentation is not as clear as you assume ;)
Don't worry, I'll try to figure something out.

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

No branches or pull requests

2 participants