React native 在react native中动态隐藏导航标头

React native 在react native中动态隐藏导航标头,react-native,React Native,我想根据redux属性动态隐藏导航标头。 这是我的密码 // navigation options static navigationOptions = ({ navigation }) => { const { params = {} } = navigation.state; console.log(params.mainFeedIsLoading); if ( typeof params.mainFeedIsLoading !== unde

我想根据redux属性动态隐藏导航标头。 这是我的密码

 // navigation options
  static navigationOptions = ({ navigation }) => {
    const { params = {} } = navigation.state;
    console.log(params.mainFeedIsLoading);

    if (
      typeof params.mainFeedIsLoading !== undefined ||
      params.mainFeedIsLoading === true
    ) {
      return {
        header: null
      };
    }

    return {
      headerTitle: <Logo type="default_logo" />,
      headerTitleStyle: { alignItems: "center" },
      headerMode: "screen",
      headerStyle: {
        paddingRight: 10,
        paddingLeft: 10
      },
      headerLeft: (
        <ClickableIcon
          source={NotificationInactive}
          height={35}
          width={35}
          onIconPressed={() => alert("Notifications Clicked")}
        />
      ),
      headerRight: (
        <ClickableIcon
          height={35}
          width={35}
          source={AddNewUserInactive}
          onIconPressed={() => alert("Add New Clicked")}
        />
      )
    };
  };
}
此处,mainFeedIsLoading变为false,但在params.mainFeedIsLoading中不受影响。我怎样才能做到这一点

this.props.navigation.setParams({ key: value });
将其放入ComponentWillReceivePropsExtProps,或者在您想要更新导航道具的任何时候。并且可以有条件地呈现标题。检查setParams和render标头中使用的“key”的条件。 我希望这会有所帮助

this.props.navigation.setParams({ key: value });