Reactjs 在导航选项中调用setstate以响应本机

Reactjs 在导航选项中调用setstate以响应本机,reactjs,react-native,react-navigation,Reactjs,React Native,React Navigation,我正在尝试更改navigationOptions中状态的值 我的导航选项 static navigationOptions = ({ navigation }) => { const { params = {} } = navigation.state; // alert(params.searchText); return { headerLeft: (params.searchText) ? <View style={{

我正在尝试更改navigationOptions中状态的值

我的导航选项

static navigationOptions = ({ navigation }) => {
    const { params = {} } = navigation.state;
   // alert(params.searchText);
    return {
      headerLeft: (params.searchText) ? <View
        style={{
          flexDirection:
            'row', justifyContent: 'center'
        }}>
        <TouchableOpacity
          onPress={()=> {
            // navigation.navigate('home');
            alert('Coming soon ');
          }}>
          <Image style={{ marginLeft: 20, height: 20, width: 20, resizeMode: "contain" }}
            source={require('../assets/header_icons/three_logo.png')}
          />
        </TouchableOpacity>
      </View> :
        <View style={{
          flexDirection:
            'row', justifyContent:
            'center'
        }}>
          <TouchableOpacity
            onPress={()=> {

            this.setState({
             loadUrl: "card.html#!/customer-dashboard?userType=Authenticated",
            showWeb:true,

           });

            }}>

            <Image style={{ marginLeft: 20, height: 20, width: 20, resizeMode: "contain" }}
              source={require('../assets/header_icons/icon_arrow_left.png')}
            />

          </TouchableOpacity>
        </View>,
    }
  }
静态导航选项=({navigation})=>{
const{params={}}=navigation.state;
//警报(参数searchText);
返回{
headerLeft:(参数searchText)?
{
//导航。导航(“主页”);
警惕(“即将到来”);
}}>
:
{
这是我的国家({
loadUrl:“card.html#!/customer dashboard?userType=Authenticated”,
showWeb:没错,
});
}}>
,
}
}
它抛出的
this.setState不是一个函数

请让我知道如何做到这一点。如何从静态
导航选项更改状态值

您可以使用redux存储。 store.js

从“redux-thunk”导入redux-thunk;
从“redux”导入{createStore、CombineReducer、applyMiddleware};
从“/reducers/auth”导入authReducer;
从“/reducers/dashboard”导入dashboardReducer;
从“/reducers/profile”导入profileReducer;
const rootReducer=combinereducer({
auth:auth,
仪表板:仪表板减速器,
轮廓:轮廓减速器
});
导出默认的createStore(rootReducer、applyMiddleware(ReduxThunk))