1

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();

Pranav Bhattad
  • 13
  • 1
  • 1
  • 4

2 Answers2

1

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} />;
0

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

asif.ibtihaj
  • 361
  • 5
  • 14