How to refresh a Page using react-route Link

Anna picture Anna · Jan 5, 2017 · Viewed 158.8k times · Source

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 and when I press the reload is goes to ../client/home)

below is my code

const AppErrorPage = () => (
    <div>
    <div style={ styles.container }>
        <h2>Error</h2>
        <p> Something went wrong, please reload the page </p>
        <div>
         <Link to="" refresh="true">
            <span>Reload</span>
          </Link>
        </div>
    </div>
    </div>  
);

Answer

Lukas Liesis picture Lukas Liesis · Jan 5, 2017

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.