为什么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函数并丢失所有数据的问题:(