我想知道是否可以使用setTimeout函數推送到其他路由。我有一個組件,它是一個加載頁面,如果加載階段完成後我想要做什麼,我會在屏幕上顯示一條消息文本,但是1秒鐘後,我會自動推送到另一個路徑。React-Native在setTimeout之後推送到其他路由
我正在使用react-native-router-flux。
const pushRoute =() => setTimeout(() => Actions.home(), 1000);
const PhotoPageOnSave = ({ photoState: { message, loading, error } }) => {
if (loading) {
return (
<Container>
<View style={styles.root}>
<Spinner size="large" color="white" />
</View>
</Container>
);
}
return (
<Container>
<View style={[styles.root, error ? { backgroundColor: '#C70018' } : null]}>
<View>
<Text style={styles.textStyle}>{message}</Text>
</View>
</View>
{() => pushRoute()}
</Container>
);
};
不要工作 – EQuimper
有什麼問題?你在看什麼? –
什麼都沒有發生我留在頁面上什麼都看不到我的消息但沒有別的什麼 – EQuimper