In React, a stateful component is a component that holds some state. Stateless components, by contrast, have no state. Note that both types of components can use props.

In the example, there are two React components. The StoreMall component is stateful and the Week component is stateless.

class StoreMall extends React.Component {
  constructor(props) {
    super(props);
    this.state = { sell: 'Everthing' };
  }
  render() {
    return <h1>I'm selling {this.state.sell}.</h1>;
  }
}
 
class Week extends React.Component {
  render() {
    return <h1>Today is {this.props.day}!</h1>;
  }
}

Leave Your Comment