Statefull component in React

Stateful Component in Reactjs


Every class component in Reactjs can be a Statefull component. A class component become Statefull under following condition

  1. It has a constructor with this.state ={ } statement
  2. A class uses the this.setState() method

With a Statefull component we can able to update UI based on various user interaction. The component will re-render the UI for us.

The state objects can be accessible through this.state.<variable> only and can be updated by calling the setState method.

The component can also updated from another component using props functions. Learn how this possible with props function. Here is the guide for you.

Remember a regular functional component is not a Statefull component. But it can be possible make them Statefull using Hooks, which is a React future.

Author: Manoj

Developer and a self-learner, love to work with Reactjs, Angular, Node, Python and C#.Net

One thought on “Statefull component in React”

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.