DocumentationRulesno-component-will-update

no-component-will-update

Rule category

Restriction.

What it does

Prevents usage of componentWillUpdate in class components.

Why is this bad?

This API has been renamed from componentWillUpdate to UNSAFE_componentWillUpdate. The old name has been deprecated. In a future major version of React, only the new name will work.

Run the rename-unsafe-lifecycles codemod to automatically update your components.

Examples

Failing

import React from "react";
 
class ExampleComponent extends React.Component {
  componentWillUpdate() {
    // ...
  }
}

Passing

import React from "react";
 
class ExampleComponent extends React.Component {
  UNSAFE_componentWillUpdate() {
    // ...
  }
}

Further Reading