# jsx-sort-default-props

Rule `react/jsx-sort-default-props`. Enforce defaultProps declarations alphabetical sorting

- Source: react
- Technologies: React
- Kind: style
- Needs type information: no
- Autofix: no
- Deprecated: yes
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #1879 by reach

## Linters

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

## Code examples

### Incorrect: the rule reports this

```jsx
var Component = createReactClass({
...
  getDefaultProps: function() {
    return {
      z: "z",
      a: "a",
      b: "b"
    };
  },
...
});

class Component extends React.Component {
  ...
}
Component.defaultProps = {
  z: "z",
  a: "a",
  b: "b"
};

class Component extends React.Component {
  static defaultProps = {
    z: "z",
    y: "y",
    a: "a"
  }
  render() {
    return <div />;
  }
}

// …
```

### Correct: the rule accepts this

```jsx
var Component = createReactClass({
...
  getDefaultProps: function() {
    return {
      a: "a",
      b: "b",
      c: "c"
    };
  },
...
});

class Component extends React.Component {
  ...
}
Component.defaultProps = {
  a: "a",
  b: "b",
  c: "c"
};

class Component extends React.Component {
  static defaultProps = {
    a: PropTypes.any,
    b: PropTypes.any,
    c: PropTypes.any
  }
  render() {
    return <div />;
  }
}

// …
```

Examples from the ESLint documentation.

## Enable it

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

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

export default [
  {
    plugins: { react },
    rules: {
      "react/jsx-sort-default-props": "error",
    },
  },
];
```

## Related rules

- [react/jsx-newline](https://lintradar.dev/rules/react/jsx-newline.md): Require or prevent a new line after jsx elements and expressions.
- [react/jsx-sort-props](https://lintradar.dev/rules/react/jsx-sort-props.md): Enforce props alphabetical sorting
- [react/jsx-child-element-spacing](https://lintradar.dev/rules/react/jsx-child-element-spacing.md): Enforce or disallow spaces inside of curly braces in JSX attributes and expressions
- [react/boolean-prop-naming](https://lintradar.dev/rules/react/boolean-prop-naming.md): Enforces consistent naming for boolean props
- [react/no-adjacent-inline-elements](https://lintradar.dev/rules/react/no-adjacent-inline-elements.md): Disallow adjacent inline elements not separated by whitespace.
- [react/prefer-read-only-props](https://lintradar.dev/rules/react/prefer-read-only-props.md): Enforce that props are read-only

---

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