what is React Native’s replacement of React’s e.target.innerText?

Good day everyone. please what is React Native’s replacement of React’s e.target.innerText? I’m trying to get what a user click on from TouchableOpacity component. I’m building a React Native quiz app. I used TouchableOpacity for the options. I’m using onPress function to get the options the user clicks on with onPress = {(e) => this.props.answer(e, question)} So creating the answer function … how do I determine if the user has chosen the correct answer. If it’s normal React I’d have used:

onAnswer = (e, newQuestion) => { e.target.innertext === questions[newQuestion].answer ? this.correct() : this.wrong()

Please help me out here.

React Native doesn’t have this. It looks like you’re looping over a list of answers and displaying buttons with the text inside. So, you should be able to reference the answer directly in your onPress, like:

answers.map(answer => (
   <TouchableOpacity onPress={() => onAnswer(question, answer)} >
      <Text>{answer}</Text>
  </TouchableOpacity>

Then adjust your onAnswer accordingly so it reads the answer directly instead of assuming it has an event object (you can actually do this in plain React, as well)