react-native - 如何刷新全屏并重新加载react-native中的所有组件
问题描述
我正在使用 react-native,react-navigation。我想使用滚动视图刷新我的应用程序的整个屏幕并重新渲染所有组件,有人可以就此提出建议吗?
解决方案
嘿,您可以首先使用NavigationEvents从 react-navigation 导入NavigationEvents。
这是我的代码。
import { NavigationEvents } from 'react-navigation';
import * as React from 'react';
import { Text, View, StyleSheet } from 'react-native';
import Constants from 'expo-constants';
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<NavigationEvents
onDidFocus={() => alert('Welcome')}
/>
<Text style={styles.paragraph}>
Hello word
</Text>
<Card>
<AssetExample />
</Card>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
paddingTop: Constants.statusBarHeight,
backgroundColor: '#ecf0f1',
padding: 8,
},
paragraph: {
margin: 24,
fontSize: 18,
fontWeight: 'bold',
textAlign: 'center',
},
});
我使用<NavigationEvents onDidFocus={() => alert('Welcome')}/>
它,它被称为 wvwer time 您打开页面。
希望对您有所帮助,请随时提出疑问。
推荐阅读
- node.js - 如何为 Function APP 生成 Azure Swagger UI
- python - 拆分并仅保留存储在 python 数据框列中的英文文本
- reactjs - 无法使用 webapck 加载图像,反应
- python - 熊猫的标题和skirows差异不清楚
- google-apps-script - 将多个 IF OR 语句分组
- python - 如何淡化来自 dynamodb 流的 json
- java - 当我们在android中使用backstack返回上一个片段时,上一个片段正在重新启动
- python - 为数独编写回溯求解器时出错
- c - Netlink:从内核多次接收数据
- world-of-warcraft - 如何修改一个角色在艾泽拉斯的可用天赋总数?