简体   繁体   English

如何在 react-native 中重新加载页面

[英]How to reload a page in react-native

How to reload a page in react-native.如何在 react-native 中重新加载页面。

In reactjs window.location.reload() worked but it is not supported in react native.在 reactjs window.location.reload() 中有效,但在本机反应中不支持。

It throws exception - Cannot read property 'reload' of undefined它抛出异常 -无法读取未定义的属性“重新加载”

window.location is a browser feature, and not available in React Native. window.location是浏览器功能,在 React Native 中不可用。

Since React Native doesn't have a router itself, the answer depends on which one you use.由于 React Native 本身没有路由器,答案取决于你使用哪一个。 Assuming you use React Router, the most popular one, you could do this:假设你使用最流行的 React Router,你可以这样做:

const history = useHistory();
history.replace(YOUR_ROUTE_HERE);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM