How to refresh a Page using react-route Link

前端 未结 3 791
一向
一向 2020-12-24 04:42

I am trying to refresh a page using react-route Link. But the way I have implemented it goes to the URL one step back.(as an example if the URL was ../client/home/register a

相关标签:
3条回答
  • 2020-12-24 05:04

    You can use this

    <a onClick={() => {window.location.href="/something"}}>Something</a>
    
    0 讨论(0)
  • 2020-12-24 05:23

    Try like this.

    You must give a function as value to onClick()

    You button:

    <button type="button" onClick={ refreshPage }> <span>Reload</span> </button> 
    

    refreshPage function:

    function refreshPage(){ 
        window.location.reload(); 
    }
    
    0 讨论(0)
  • 2020-12-24 05:25

    To refresh page you don't need react-router, simple js:

    window.location.reload();
    

    To re-render view in React component, you can just fire update with props/state.

    0 讨论(0)
提交回复
热议问题