Skip to content
Advertisement

How to reload current page in ReactJS?

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.

JavaScript

Advertisement

Answer

Since React eventually boils down to plain old JavaScript, you can really place it anywhere! For instance, you could place it in a `componentDidMount()’ function in a React class.

For your edit, you may want to try something like this:

JavaScript
Advertisement