How to reload current page in ReactJS? in case of javascript we can write window.location.reload();
How to do the same in Reactjs? I'm able to add new data by UI. But without refreshing, I'm not able to see the list. I want it so that whenever I'm adding some data, it refreshes by itself.
onAddBucket() { let self = this; let getToken = localStorage.getItem('myToken'); var apiBaseUrl = "..."; let input = { "name" : this.state.fields["bucket_name"] } axios.defaults.headers.common['Authorization'] = getToken; axios.post(apiBaseUrl+'...',input) .then(function (response) { if(response.data.status == 200){ let result = self.state.buckets.concat(response.data.buckets) }else{ alert(response.data.message); } }) .catch(function (error) { console.log(error); }); }
While holding, press refresh ⟳. Using Chrome on mobile, go to ⋮ (Android) or … (iOS) > Settings > Privacy > Clear Browsing Data > Clear Browsing Data (iOS) or Clear Data (Android).
You can use the location. reload() JavaScript method to reload the current URL. This method functions similarly to the browser's Refresh button. The reload() method is the main method responsible for page reloading.
use this might help
window.location.reload();
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