3

Why is this onPress activated at any time without pressing TouchableOpacity when I change any property of state if project_id is not null?

<TouchableOpacity
  onPress={() => {
    if (this.state.feedback.project_id != null) {
      this.setModalVisible(true);
    } else {
      Alert.alert('Select a project please');
    }
  }}>
  <View>
    <Text>SEND NOW</Text>
  </View>
</TouchableOpacity>

Example process:

  1. I press this touchable and project_id == 1 , modal will open.
  2. I close the modal
  3. I change feedback.name with a textinput
  4. Because project_id is still 1 modal will open
Matei Radu
  • 2,038
  • 3
  • 28
  • 45
Cookie
  • 352
  • 4
  • 16
  • Can you be more specific please ? I am lost after you close the modal. "3- I change feedback.name with a textinput 4- Because project_id is still 1 modal will open" <-- i didnt understand this one – Nezih Oct 05 '18 at 08:10
  • @Cookie please the relevant code. – Hemadri Dasari Oct 05 '18 at 08:11
  • Now I see that the problem is another... I active the modal in this screen, but modal is an import component that I do visible or invisible in this import, and in first screen modalvisible remains true On close modal I would have to change fist screen, but I don't know how to do it – Cookie Oct 05 '18 at 08:18
  • I can not help you until you provide me more source code and being "CLEAR" on that issue. – Nezih Oct 05 '18 at 08:19
  • I create a new question to explain myself better – Cookie Oct 05 '18 at 09:01
  • look https://stackoverflow.com/questions/52662641/react-native-change-state-of-screen-when-close-import-modal – Cookie Oct 05 '18 at 09:39

0 Answers0