如何使用react-route链接刷新页面 [英] How to refresh a Page using react-route Link
本文介绍了如何使用react-route链接刷新页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用react-route链接刷新页面.但是我实现它的方法是将URL退后一步.(例如,如果URL是../client/home/register,而当我按下重新加载时,URL是../client/home)
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)
下面是我的代码
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>
);
推荐答案
要刷新页面,您无需使用react-router,简单的js:
To refresh page you don't need react-router, simple js:
window.location.reload();
要在React组件中重新渲染视图,您可以使用props/state触发更新.
To re-render view in React component, you can just fire update with props/state.
这篇关于如何使用react-route链接刷新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文