Web / React native Interview questions
What is State and how is it used in React Native?
It is used to control the components. The variable data can be stored in the state. It is mutable means a state can change the value at any time.
const HomeScreen = React.memo(({ navigation }) => { console.log('HomeScreen rendered'); const [myState, setMyState] = useState("Test Value"); const updateState = () => { setMyState('The state is updated') } return ( <View> <Text onPress={updateState}> {myState} </Text> </View> ); });
More Related questions...