保存以前的场景状态

时间:2018-07-09 09:16:59

标签: javascript react-native react-router-native

我正在使用“ react-router-native”,并且有项目列表。当我按“链接”时,我会打开项目的详细信息页面。

但是当我返回时,组件的列表开始重新呈现。

这是主要组成部分

<Provider store={store}>
    <NativeRouter>
      <Switch>
        <Route path="/filters" component={Filters}/>
        <Route path="/settings" component={Settings}/>
        <Route path="/detail/:id" component={RestaurantDetail}/>
        <Route path="/review/:id" component={Review}/>
        <Route exact path="/" component={Init}/>
        <Route path="/" render={() => (
          <View style={{paddingTop: Platform.OS === 'ios' ? 20 : 0}}>
            <Header/>
            <View>
              <Route exact path="/restaurants" component={Restaurants}/>
              <Route path="/map" component={RestaurantsMap}/>
              <Route path="/products" component={Products}/>
              <Route path="/events" component={Events}/>
              <Route path="/deals" component={Deals}/>
            </View>
          </View>
        )}/>

      </Switch>
    </NativeRouter>
  </Provider>

当我转到另一个页面然后返回时如何保存列表组件?

0 个答案:

没有答案