peterp / react-native-tags

Tag input component for React Native
MIT License
288 stars 75 forks source link

undefined is not an object (evaluating 'event.persist') #66

Closed hakimscode closed 2 years ago

hakimscode commented 4 years ago

Hello, I'm trying to add simple tags to my app. But I have a problem in onPress handler when I'm trying to delete pressed tag.

here's my code

<Tags
  textInputProps={{
    placeholder: "describe your tags here"
  }}
  onChangeTags={tags => setTags(tags)}
  onTagPress={(index, tagLabel, event, deleted) =>
    console.log(index, tagLabel, event, deleted ? "deleted" : "not deleted")
  }
  containerStyle={{ justifyContent: 'center' }}
  inputStyle={{ backgroundColor: '#F4E4E4' }}
  renderTag={({ tag, index, deleteTagOnPress, onPress }) => (
    <TouchableOpacity key={`${tag}-${index}`} onPress={onPress} style={styles.tags}>
      <Text style={styles.textTags}>{tag}</Text>
    </TouchableOpacity>
  )}
/>

Expected Behaviour Tag that pressed should be deleted

Actual Behavior I got an error

undefined is not an object (evaluating 'event.persist')

But, when I try open react-native-tags in node_modules and delete/comment the line where the event.persist(); in index.js file, everything works fine.

What should I do beside changing the code in the node_modules to get everything works fine

I have also tried onPress={(e) => onPress(e)} onPress={() => onPress()} but still not working

Thanks

wanxsb commented 3 years ago

I have the same problem.

peterp commented 3 years ago

I believe event.persist is deprecated. I think we can modify that line to read something like: event?.persist()

Please open a PR

btuck044 commented 3 years ago

@peterp PR is up https://github.com/peterp/react-native-tags/pull/90

peterp commented 2 years ago

Closed by #90