no-default-props
Full Name in eslint-plugin-react-x
react-x/no-default-props
Full Name in @eslint-react/eslint-plugin
@eslint-react/no-default-props
Features
🔍
Presets
core
recommended
recommended-typescript
recommended-type-checked
What it does
Disallows using defaultProps
property in favor of ES6 default parameters.
The defaultProps
will be removed from functional components in React 19 in place of ES6 default parameters. If you’re using defaultProps
, it is recommend to 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>;
}