I'm pretty new to the idea of states in react native and have trouble using them to change the states of the components. I have three text components one which is a question and another two are answers (yes and no), and another text component that checks if my answer to the question is write, so the check text component. When I click on yes for a certain question the state of the last check component should change to 'right' if the answer was yes or to 'wrong' if the answer is no. So basically, this is what I want to do :
So, the idea is when i click on yes and then check the pop-up should be this. This is the code I have so far:
import React, {useState} from 'react';import { StyleSheet, Text, View, Button } from 'react-native';export default function App() { const [myState, setMyState] = useState('Yes'); const [myState2, setMyState2] = useState('Right'); const updateState = () => { let tempStr = myState; if (tempStr == "Yes"){ setMyState2('Right'); } else{ setMyState2('Wrong'); };}return (<View style={{alignItems: 'center', top: 150}}><Text>Is the earth round?</Text><Text mystate={setMyState}>Yes</Text><Text mystate={setMyState}>No</Text><Text mystate2={setMyState2}>Check</Text></View> );}
Currently, none of my text components seem to work.Can anyone tell me how it could be done. Thanks!