-
Notifications
You must be signed in to change notification settings - Fork 326
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
Routes not rendering components when navigating #504
Comments
I'm having the same issue. Currently using React 18.0 and very recent create-react-app project. |
I am also having same issue in vite. Refresh of page loads it.
Downgrading to react/react-dom 17.0.2 seems to workaround it. Also used [email protected] and it worked (looks like it uses old react-dom shape) like this in vite.config.js: const { defineConfig } = require('vite')
const react = require('@vitejs/plugin-react')
const { resolve } = require('path')
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
'~': resolve(__dirname, './src'),
react: 'preact/compat',
'react-dom': 'preact/compat'
}
}
}) |
Same here, used Create React App today and the navigation on click does not work. |
Same issue here, used Create React App, working under windows, using cross-env at npm start |
I discovered that Reach/router and react-router joined forces. I personally decided to switch back to React Router V6 which makes embedded routers work just like they worked within Reach. |
@jenapidev @romainbessugesmeusy @chrisl777 @konsumer found a workaround: |
The problem is in the ReactDOM.render function |
I've run into the same issue on an app we recently upgraded to React 18. Then, based on @romainbessugesmeusy's comment I looked into React Router v6. This comes from their Reach Router migration guide:
https://reactrouter.com/docs/en/v6/upgrading/reach The migration process was relatively smooth for me, albeit with a lot of manual testing. Be aware that some things from Reach Router are missing, e.g. the |
I just had the same issue running a React app on Vitejs and it seems when I remove |
Woked for me thanks! |
This worked for me too, many thanks |
This worked for me too, thanks!! |
Yeah Removing StrictMode Fixes the problem. Will there be any issues in the future for not using StrictMode? |
"StrictMode is a tool for highlighting potential problems in an application." - So I assume this is good to have. :) |
I have the same issue. Neither navigate or Link render the page and removing strict mode did not fix it. |
lol and now that it highlighted a problem, you will remove it and act like a problem does not exist. (it worked for me btw) |
We're using React 18.2 and removing StrictMode didn't have an effect. Using |
This works for me..thanks :-) |
I had a similar issue in which the routing would change the url but had no effect on the page view. My initial code was:
); I figured when I use 'element' instead of 'component', it works. Below is the updated code: `function App() {
); |
@Gechrist , is your issue resolved, I am also facing the same issue and none of the above solutions works for me. |
@Anurag-kuswaha, it was an issue on my end that was causing the problem. It had nothing to do with react-router. |
Thanks for the reply, @Gechrist , and this issue is happening only on the production build and working fine on the development in our project we have used this version:
please let me know if you have faced this type of issue already or have any idea how can we resolve this issue. 😃 |
Hi @Anurag-kuswaha |
hey @FarhanSulaiman , we haven't got the solution yet and we are still looking into the issue, will let you know if we find anything. and as far as we found it looks more like a package issue, can you please let me know, what are all the packages that you have used in your project? |
Hi @Anurag-kuswaha ,
|
thanks @FarhanSulaiman for sharing the package version, it looks issue is because of react, react-dom or react-router-dom only, please let us know if you finds any solution |
Facing the same issue from last 2 days. "react": "^18.2.0", |
hi @rajuchowdary , @FarhanSulaiman , this issue is caused because of recent changes in the react-router-dom package file which created this issue. |
Still its not working for me using this versions "react": "^18.2.0", |
|
Why: - We were using a pre-release version of React concurrent mode, but it has already been released officially, so it's time to upgrade. - React's StrictMode causes the elements to be mounted twice, which caused two the OpenLayers Maps to be created inside the div. The fix was to implement componentWillUnmount and destroy the Map on unmount. - Reach Router is incompatible with React 18, and StrictMode causes navigation to not work. There will be no Reach Router v2, so the fix is to migrate to React Router v6. reach/router#504 https://reactrouter.com/en/main/upgrading/reach - React Router doesn't have the equivalent of Reach Router's globalHistory, so we used the useEffect workaround from remix-run/remix#5999
thanks for this.. |
Not working for me. Has there been any mention of a fix for this?
|
Tried many solutions, but this is still the only one that worked for me. Thanks! |
I changed: It worked for me... |
In your index.js file, just remove the <React.StrictMode> tag. In my case, it solved the problem.
|
Have tried all the methods mentioned above and they didn't work for me.
|
Seeing the same thing:
Have tried removing React.StrictMode, which did nothing. Also attempted to use ReactDOM.render, however that appears to have been removed in my version. Update This turned out to be user error. It turns out that when navigating between nested routes, the same component instance is re-used (but new props are passed in based on params). In my case, I was using I fixed by adding a key prop to my page component that is set based on route params. |
Hello, I was having this issue too after the react version update(v18.3.0). Issue Line 101 in d2c9ad0
How I solve
|
When using navigate or redirect the route changes but doesn't render any component
Router:
The component Login only renders if i reload the pahe on the "/login" route
dependencies:
"@reach/router": "^1.3.4",
"@types/react-dom": "^17.0.14",
"bootstrap": "^5.1.3",
"node-sass": "^7.0.1",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-redux": "^7.2.8",
"react-scripts": "5.0.0",
"reactstrap": "^9.0.1",
"redux": "^4.1.2",
"redux-devtools-extension": "^2.13.9",
"redux-thunk": "^2.4.1",
"sass": "^1.49.11",
"typescript": "^4.6.3"
"@types/node": "^16.11.26",
"@types/reach__router": "^1.3.10",
"@typescript-eslint/eslint-plugin": "^5.18.0",
"@typescript-eslint/parser": "^5.18.0",
"eslint": "^8.11.0",
"eslint-config-async": "^1.0.1",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.2.0",
"eslint-plugin-react": "^7.29.4"
The text was updated successfully, but these errors were encountered: