# default-props-match-prop-types

Rule `react/default-props-match-prop-types`. Enforce all defaultProps have a corresponding non-required PropType

- Source: react
- Technologies: React
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 3.4M weekly downloads of presets that enable it
- Trend: +2.3% last quarter
- Rank: #1433 by reach, #1569 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `react/default-props-match-prop-types` | no | no | package `eslint-plugin-react` | [docs](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules/default-props-match-prop-types.md) |

## Code examples

### Incorrect: the rule reports this

```jsx
function MyStatelessComponent({ foo, bar }) {
  return <div>{foo}{bar}</div>;
}

MyStatelessComponent.propTypes = {
  foo: React.PropTypes.string.isRequired,
  bar: React.PropTypes.string
};

MyStatelessComponent.defaultProps = {
  foo: "foo"
};
```

```jsx
var Greeting = React.createClass({
  render: function() {
    return <div>Hello {this.props.foo} {this.props.bar}</div>;
  },

  propTypes: {
    foo: React.PropTypes.string,
    bar: React.PropTypes.string
  },

  getDefaultProps: function() {
    return {
      baz: "baz"
    };
  }
});
```

```jsx
class Greeting extends React.Component {
  render() {
    return (
      <h1>Hello, {this.props.foo} {this.props.bar}</h1>
    );
  }
}

Greeting.propTypes = {
  foo: React.PropTypes.string.isRequired,
  bar: React.PropTypes.string
};

Greeting.defaultProps = {
  foo: "foo"
};
```

### Correct: the rule accepts this

```jsx
function MyStatelessComponent({ foo, bar }) {
  return <div>{foo}{bar}</div>;
}

MyStatelessComponent.propTypes = {
  foo: React.PropTypes.string,
  bar: React.PropTypes.string.isRequired
};
```

```jsx
function MyStatelessComponent({ foo, bar }) {
  return <div>{foo}{bar}</div>;
}

MyStatelessComponent.propTypes = {
  foo: React.PropTypes.string.isRequired,
  bar: React.PropTypes.string
};

MyStatelessComponent.defaultProps = {
  bar: 'some default'
};
```

```jsx
type Props = {
  foo: string,
  bar?: string
};

function MyStatelessComponent(props: Props) {
  return <div>Hello {props.foo} {props.bar}</div>;
}

MyStatelessComponent.defaultProps = {
  bar: 'some default'
};
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import react from "eslint-plugin-react";

export default [
  {
    plugins: { react },
    rules: {
      "react/default-props-match-prop-types": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Airbnb](https://lintradar.dev/presets/airbnb.md) | ESLint | `eslint-config-airbnb` | 346 | 3.4M | +2.3% |

## Related rules

- [react/destructuring-assignment](https://lintradar.dev/rules/react/destructuring-assignment.md): Enforce consistent usage of destructuring assignment of props, state, and context
- [react/state-in-constructor](https://lintradar.dev/rules/react/state-in-constructor.md): Enforce class component state initialization style
- [react/forbid-prop-types](https://lintradar.dev/rules/react/forbid-prop-types.md): Disallow certain propTypes
- [react/no-will-update-set-state](https://lintradar.dev/rules/react/no-will-update-set-state.md): Disallow usage of setState in componentWillUpdate
- [react/jsx-closing-bracket-location](https://lintradar.dev/rules/react/jsx-closing-bracket-location.md): Enforce closing bracket location in JSX
- [react/jsx-props-no-spreading](https://lintradar.dev/rules/react/jsx-props-no-spreading.md): Disallow JSX prop spreading

---

Web page: https://lintradar.dev/rules/react/default-props-match-prop-types. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
