Ad

React Router Link ForceUpdate

- 1 answer

i want to refresh whole page when user click home button. I am using

this<Link onClick={this.forceUpdate} to="/">HOME</Link>

It works as expected, but i have this error. Any idea why i am getting it ?

Cannot read property 'enqueueForceUpdate' of undefined

I am assuming that this is not defined, not sure why tho. Thanks for any help.

Ad

Answer

You can use this when someone clicks on Home :

onClick={()=>{window.location.href = '/';}}

This will navigate user to Home page and refresh the App.

Ad
source: stackoverflow.com
Ad