I have a simple question. I have a REACTjs application which does some requests to the API when starting. These requests are usually done only once but once in a while, user might want to refresh the application manually.
When performing ctrl+F5 (or refresh the page via browser), it works fine.
I tried adding a button with the same functionality like this to my application:
<button value="Refresh Page" onClick="window.location.reload(true)">Refresh</button>
but it only performs two requests: 0.junk.js and 0.junk.js.map which both returns 304 status.
Is there a way how to achieve the same behavior as refreshing with browser?
Try calling a function:
onClick={() => window.location.reload(true)}
Or Simply update any state of your main component:
this.setState({ refresh: true })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With