React native React Native NavigatorIOS赢得';重新渲染组件

React native React Native NavigatorIOS赢得';重新渲染组件,react-native,React Native,我有一个带有多个TabBar.Item组件的TabBar。每个TabBar.Item组件都有自己的导航器 下面是我的TabBar.js <TabBarIOS> <TabBarIOS.Item selected={this.state.selectedTab === "profile"} systemIcon={"most-viewed"} onPress={() => this.setTab("profile")} > <

我有一个带有多个TabBar.Item组件的TabBar。每个TabBar.Item组件都有自己的导航器

下面是我的
TabBar.js

<TabBarIOS>
  <TabBarIOS.Item
    selected={this.state.selectedTab === "profile"}
    systemIcon={"most-viewed"}
    onPress={() => this.setTab("profile")}
  >
    <NavigationBar title="Profile" component={Profile} passProps={{ showFilter: this.state.showFilter }} />
  </TabBarIOS.Item>
</TabBarIOS>
当用户单击
过滤器
按钮时,
此.state.showFilter
选项卡栏
中更新。然后它被正确地传递到
NavigationBar
中,但是
NavigationBar
中的
render()
函数被执行

此时,我的组件不会重新呈现
初始路由中列出的组件
(配置文件)


有没有办法做到这一点?单击过滤器时,我需要在
配置文件
中设置一个可选变量,以隐藏和显示过滤器
模式
我不确定是否有更优雅的解决方案,但我有一个可行的解决方案

我在
导航栏
中添加了以下代码:

shouldComponentUpdate(nextProps, nextState) {
    this.refs.nav.replace({...nextProps})
    return true;
  }

这将强制重新加载
initialRoute
组件

我不知道IOS,但这个问题似乎提供了一个可能的解决方案:感谢您的评论,这与React Native(JavaScript)更相关,与Swift/Objective-C(您提供的链接中的内容)相对应
shouldComponentUpdate(nextProps, nextState) {
    this.refs.nav.replace({...nextProps})
    return true;
  }