React Router Is Changing The Url But Not Loading The Webpage Properly
I am working on a React JS project, inside the project I am using React Router v4 to create a client-side route. This is the project live URL: https://gokhana.herokuapp.com/ On the
Solution 1:
After a lot of studies, I found the answer to my problem.
In React Router, if we redirect to the new route then JS libraries are not loaded. In my case, I was using the plugins which were injecting the HTML elements after the page load is complete.
Now, react routing will not load the page as everything here is virtual DOM, so the solution here was to load the JS libraries after routing is done.
So I used loadjs package.
1) Install
yarn add loadjs
2) Import
import loadjs from'loadjs';
3) Call it in componentDidMount() of the React Component
loadjs('./js/modernizr.js', () => {});
and this will resolve the problem.
Post a Comment for "React Router Is Changing The Url But Not Loading The Webpage Properly"