-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
React-Router only rendering the first route #6163
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
Comments
Can you drop this into codesandbox.io? What URL are you hitting? This might be as simple as a misunderstanding of the API, but there is missing information needed to determine that. |
Sure thing. Here is the link. I'm hitting the ones by the Link rendered in the first component, but then it doesn't go anywhere. :\ I feel I haven't missed anything because I followed another project schema I have similar to the one I had first before narrowing it down to the most simple example shown in the codesandbox link. |
I think I just stumbled upon that one too. I'll provide a small reproduction demo and will try to narrow down the problem Thanks for the awesome work! |
I'll be closing this issue because I found out what my problem was (or at least a workaround). First, when I wrote the basic example that wasn't working, I misused one of the properties. Instead of "path", I wrote "route". Welp, problem solved. Second, the issue was mostly when I wanted to export the Switch component in one file, and then import it to another with the Router component... Something like this:
Anyways, I'm closing this since I'll have to go around with another solution. Is there any explanation why this doesn't work this way? |
Situation:
I've done work with React-Router before, but after updating to +16.3, all went downhill from there. Been reading in the issues here to see if I could find a similar situation, and it seems the new context api is breaking react router (as seen in this thread), but then I proceeded to do something smaller to see if there was a way to go around it, and it didn't work. Then went back into something basic, and nothing! It always renders the first Route on Switch despite the fact I'm telling Redirect to render another one.
Note: The project was created using create-react-app, so webpack configuration was not changed.
Test Case
Routes are broken. React Router always renders first route on Switch, even tho Redirect component has another route to render to render first.
Steps to reproduce
Expected Behavior
First, to render the Redirect route, then switch routes when clicked on Links.
Actual Behavior
Renders first Route on Switch, even when is not the first one it should render while using Redirect.
The text was updated successfully, but these errors were encountered: