logoESLint React
Rules

no-default-props

Full Name in @eslint-react/eslint-plugin

@eslint-react/no-default-props

Full Name in eslint-plugin-react-x

react-x/no-default-props

Presets

x recommended recommended-typescript recommended-type-checked strict strict-typescript strict-type-checked

Description

Disallows the defaultProps property in favor of ES6 default parameters.

The defaultProps property will be removed from functional components in React 19 in favor of ES6 default parameters. If you’re using defaultProps, it is recommended that you migrate to ES6 default parameters.

Examples

Failing

import React from "react";

function MyComponent(props) {
  return <div>{props.name}</div>;
}

MyComponent.defaultProps = {
  name: "John Doe",
};

Passing

import React from "react";

interface MyComponentProps {
  name: string;
}

function MyComponent({ name = "John Doe" }: MyComponentProps) {
  return <div>{name}</div>;
}

Implementation


See Also

  • no-prop-types
    Disallows using the propTypes property in favor of TypeScript or another type-checking solution.

On this page