Javascript 在另一个屏幕中更改状态也会更改抽屉激活的状态

Javascript 在另一个屏幕中更改状态也会更改抽屉激活的状态,javascript,reactjs,react-native,Javascript,Reactjs,React Native,在我的DroperNavigator中,我有配置文件屏幕和许多其他屏幕,但出于这个问题的目的,我将以我的配置文件屏幕为例。这就是我如何设置抽屉的方法 Navigation.js 你在用redux吗。我已经安装了你的应用程序,但我不确定如何使用它。我已经在我的应用程序中设置了提供者和存储。jstry to learn redux,它将提供可在任何组件中访问的存储,您可以使用数据并更新数据。这将自动替换应用程序中的任何位置app@PrakashKarena嘿我刚刚学会了redux,但我在改变状态时遇

在我的DroperNavigator中,我有配置文件屏幕和许多其他屏幕,但出于这个问题的目的,我将以我的配置文件屏幕为例。这就是我如何设置抽屉的方法

Navigation.js
你在用redux吗。我已经安装了你的应用程序,但我不确定如何使用它。我已经在我的应用程序中设置了提供者和存储。jstry to learn redux,它将提供可在任何组件中访问的存储,您可以使用数据并更新数据。这将自动替换应用程序中的任何位置app@PrakashKarena嘿我刚刚学会了redux,但我在改变状态时遇到了问题,并发布了另一个问题
const AppDrawerNavigator = createDrawerNavigator(
  {
    Home: { screen: DashboardStackNavigator },
    Profile: { screen: ProfileStack },
    Calendar: { screen: CalendarStack },
    Rewards: { screen: RewardsStack },
    FeedbackForm: { screen: FeedbackStack },
    ChangePassword: { screen: ChangePasswordStack },
    Login: { screen: Login },
  },
  {
    contentComponent: ({ navigation }) => <DrawerContainer navigation={navigation} />
  }
);
            <TouchableOpacity
              onPress={() => this.props.navigation.navigate('Profile')}>
              <Image
                source={{ uri: items[0].imageUrl }}
                style={styles.photo} />
            </TouchableOpacity>
          <TouchableOpacity
            onPress={() => this.selectImage()}>
            <View style={styles.piccontainer}>
              <Image
                source={{ uri: this.state.items[0].imageUrl }}
                style={styles.photo} />
            </View>
          </TouchableOpacity>
          <TouchableOpacity style={styles.button}
              onPress={() => {
                this.uploadImage();
                this.goBack()
              }}>
              <View>
                <Text style={styles.text}>Save</Text>
              </View>
          </TouchableOpacity>

//uploadImage(), uploading image to s3 and updating the link in my webapi
uploadImage = () => {
    this.setState({
      loading: true
    })
    let file = this.state.file;
    let config = this.state.config;
    const { navigation } = this.props
    RNS3.put(file, config)
      .then((response) => {
        this.setState({
          items: this.state.items.map((item, i) =>
            i == 0 ?
              { ...item, imageUrl: response.headers.Location } : item),
          params: {
            ImageUrl: response.headers.Location,
            EmployeeBio: this.state.items[0].employeeBio
          },
        }, () => { this.updateProfileData(this.state.params) })
      })
  }

//goBack(), return to previous screen
goBack = () => {
    const { navigation } = this.props;
    navigation.goBack();
  }
  componentDidMount() {
    const { navigation } = this.props;
    this.focusListener = navigation.addListener('didFocus', () => {
      // The screen is focused
      this.getProfileData();
    });
  }

  componentWillUnmount() {
    // Remove the event listener
    this.focusListener.remove();
  }