The state is used to control the components. State also allows the variable data to get stored in it. As states are mutable, they can change the values at any point in time.

In this example, we are creating the Text component with the help of state data. Content in the text component can be updated anytime by clicking on it. However, the state needs to be updated by the event “onPress”.

BY Best Interview Question ON 03 Mar 2023

Example

import React, {Component} from 'react';    
import { Text, View } from 'react-native';    
export default class App extends Component {    
      state = {
           myState: 'React Native Interview Questions'
      }
updateState = () => this.setState({myState: 'React Native Interview Questions and Answers'})
render() {
     return (
               
               {this.state.myState}     
          

     );
} }