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>

Try it »

Output of above example-

ReactJs Reload Page

Advertisements

Add Comment

📖 Read More