What is state in React JS?

Open 1 Answers 5 Views Education
What is state in React JS?

1 Answer


State of a component is an object that holds some information that may change over the lifetime of the component. We should always try to make our state as simple as possible and minimize the number of stateful components.

Let's create a user component with message state,

class User extends React.Component {
  constructor(props) {

    this.state = {
      message: 'Welcome to React world'

  render() {
    return (


State is similar to props, but it is private and fully controlled by the component. i.e, It is not accessible to any other component til the owner component decides to pass it.

by (280k points)