Skip to content

Latest commit

 

History

History
33 lines (23 loc) · 706 Bytes

no-unnecessary-class-component.md

File metadata and controls

33 lines (23 loc) · 706 Bytes

no-unnecessary-class-component

Unnecessary class components are not allowed.

Rule Details

Class components that do not use any Error Handling-related functionality should be converted to function components.

Examples of incorrect code for this rule:

class MyComponent1 extends React.Component {
  render() {}
}

Examples of correct code for this rule:

class MyComponent1 extends React.Component {
  static getDerivedStateFromError() {}
  render() {}
}

class MyComponent2 extends React.Component {
  componentDidCatch() {}
  render() {}
}

Further Reading