Reactjs 我可以使用react导航和redux,同时保持它们的分离吗?

Reactjs 我可以使用react导航和redux,同时保持它们的分离吗?,reactjs,react-native,react-native-navigation-v2,Reactjs,React Native,React Native Navigation V2,我正在尝试使用redux和react本机导航来编写react本机应用程序。但是,我实际上不想在redux中保存导航状态。所以我只想让他们彼此分开。我目前有StackNavigator,它被包装在一个连接中,然后由提供者包装 const mapStateToProps = state => state; const mapDispatchToProps = dispatch => dispatch; // need this Higher Order Component so you

我正在尝试使用redux和react本机导航来编写react本机应用程序。但是,我实际上不想在redux中保存导航状态。所以我只想让他们彼此分开。我目前有StackNavigator,它被包装在一个连接中,然后由提供者包装

const mapStateToProps = state => state;
const mapDispatchToProps = dispatch => dispatch;

// need this Higher Order Component so you can pass properties through the root stack
const AppContainer = connect(mapStateToProps, mapDispatchToProps)(RootStack);

export default class App extends Component {
  render() {
    return (
        <Provider store={Store}>
          <AppContainer />
        </Provider>
    );
  }
}
const-mapStateToProps=state=>state;
const mapDispatchToProps=调度=>调度;
//需要此高阶组件,以便可以通过根堆栈传递属性
const-AppContainer=connect(mapStateToProps,mapDispatchToProps)(根堆栈);
导出默认类应用程序扩展组件{
render(){
返回(
);
}
}

这种实施可能吗?

是的,这是可能的,事实上,这是鼓励的

来自react导航文档的报价:

有些人喜欢将导航状态存储在与其应用程序状态其余部分相同的位置。三思而后行,这是一个非常好的机会,你不需要这样做!如果您不知道自己在做什么,在自己的Redux商店中存储您的React导航状态可能会给您带来非常困难的时间

默认情况下,Redux和React导航互不相关,在其下一版本(2018年秋季)中,将不会记录或鼓励将React导航集成到Redux状态