I want to reload my ReactJS Page without refreshing it! There will be 'reload icon' in the page if some person click it then it should not Reload the page it should be single Page only!
Don't tell window.location.reload();
I want to reload my ReactJS Page without refreshing it! There will be 'reload icon' in the page if some person click it then it should not Reload the page it should be single Page only!
Don't tell window.location.reload();
consider conditionally early returning the Redirect
component : https://reactrouter.com/web/api/Redirect
so on your button click; setReload(true);
in your page component:
// before your regular return
if(reload) return <Redirect to={window.location.pathname} />;
If your component is a class component you can use this code below in the click function. this.forceUpdate()
.
if your component is a functional one you can follow this answer