为什么对所有路线都在快速刷新上进行响应导航调用componentWillUnmount?

时间:2019-11-20 13:33:54

标签: react-native react-navigation

为什么Async每次都在所有路径的快速刷新上调用react-navigation? 我的应用看起来像:

componentWillUnmount

Navigator.ts

import { createAppContainer } from "react-navigation"; import { createStackNavigator } from "react-navigation-stack"; import Chat from "app/screens/Chat"; import Home from "app/screens/Home"; const Navigator = createStackNavigator( { Home: Home, Chat: Chat, }, { initialRouteName: "Home", }, ); export default createAppContainer(Navigator);

App.tsx

... import Navigator from "app/screens/Navigator"; class App extends React.PureComponent<Props> { ... render() { return ( <Wrapper> <StatusBar barStyle="light-content" /> <ErrorBoundary> <Navigator /> </ErrorBoundary> </Wrapper> ); } }

Home.tsx

每次class Home extends React.PureComponent<Props> { ... componentWillUnmount() { this.props.clearReduxStore() } render() { return ( <View> <Text>Some content<Text> </View> ); } } 调用时,我都面临着redux clear store函数并丢失所有数据的问题:(

0 个答案:

没有答案