How do I reload a page with react-router?

后端 未结 13 1809
臣服心动
臣服心动 2020-12-09 08:23

I can see in this file (https://github.com/ReactTraining/react-router/blob/v0.13.3/modules/createRouter.js) that there is a refresh function but I have no idea how to call i

13条回答
  •  清歌不尽
    2020-12-09 09:06

    firstly, add react-router as a dependency

    `yarn add react-router` or `npm install react-router`
    
    import { useHistory } from 'react-router'
    

    const history = useHistory()

    /////then add this to the funtion that that is called for re-rendering
    

    history.go(0)

    This causes your page to re-render automatically

提交回复
热议问题