在React-native-navigation-wix中动态更改CustomNavBar按钮

时间:2018-08-06 10:29:11

标签: react-native-navigation wix-react-native-navigation

我需要使用onPress动态更改customNavbar按钮,如下所示:

首先,我将导航栏加载到componentDidMount中,这部分工作正常

componentDidMount(){
this.props.navigator.setStyle({
      navBarCustomView: 'CustomHeader',
      navBarComponentAlignment: 'center',
      topBarElevationShadowEnabled: false,
      navBarNoBorder: false,
      navBarTransparent: true,
      screenBackgroundColor: 'white',
      navBarBackgroundColor: 'white',
      navBarCustomViewInitialProps: {
        rightComponentRightSide: (
          <NavButton title="Next" onPress={onClickNext} />
        ),
      },
    });
}

然后我需要在用户按下next按钮时,将按钮更改为其他自定义按钮,这种方式让我很累,但是它不起作用

onClickNext() {
        this.props.navigator.setStyle({
          navBarCustomView: 'CustomHeader',
          navBarComponentAlignment: 'center',
          topBarElevationShadowEnabled: false,
          navBarNoBorder: false,
          navBarTransparent: true,
          screenBackgroundColor: 'white',
          navBarBackgroundColor: 'white',
          navBarCustomViewInitialProps: {
            rightComponentRightSide: (
              <LoadButton title="loading" />
            ),
          },
        });
      }

0 个答案:

没有答案