• +91 9723535972
  • info@interviewmaterial.com

ReactJS Interview Questions and Answers

Related Subjects

Question - What is a State in React?

Answer -

The State is an updatable structure which holds the data and information about the component. It may be changed over the lifetime of the component in response to user action or system event. It is the heart of the react component which determines the behavior of the component and how it will render. It must be kept as simple as possible.

Let's create a "User" component with "message state."

import React from 'react'  
  
class User extends React.Component {  
  constructor(props) {  
    super(props)  
  
    this.state = {  
      message: 'Welcome to JavaTpoint'  
    }  
  }  
  
  render() {  
    return (  
     
  
       

{this.state.message}

  
     
  
    )  
  }  
}  

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners