ReactJS Reload Page
You can use location object reload method to reload the page. Here in this tutorial, we are going to explain how to reload the current page in reactjs. You can also use our online editor to edit and run the code online.
ReactJS Reload Page Example
You can reload the page simply as below-
Example:
<script> function MyFunction(){ function reloadPage(e) { e.preventDefault(); location.reload(); } return ( <a href="#" onClick={reloadPage}> Click me </a> ); } ReactDOM.render( <MyFunction />, document.getElementById('root') ); </script> |
Output of above example-
Advertisements
Add Comment
📖 Read More
- 1. ReactJS check element exists in Array
- 2. React Pass Component As Prop with Props | ReactJs
- 3. ReactJs Round to two decimal places