Is ReactJS "clever" when it comes to invoking the render method?

Viewed 57

The render method of this component does use any of the props supplied to the component.

Will the component re-render when the props change regardless?

class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    const { propValue } = props;
    // do something with propValue...
  }
  render () {
    return (
      <div>foo</div>
    );
  }
}
3 Answers

As far as i know react will call the render method in the following scenarios

  1. when your component get mounted initially
  2. when state got changed using this.setState()
  3. when your component receives new props
  4. when this.forceUpdate() get called.

since you didn't implement shouldcomponentUpdate() the render method is going to get called

Related