# prefer-read-only-props

Rule `react/prefer-read-only-props`. Enforce that props are read-only

- Source: react
- Technologies: React
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #1883 by reach

## Linters

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

## Code examples

### Incorrect: the rule reports this

```jsx
type Props = {
  name: string,
}
class Hello extends React.Component<Props> {
  render () {
    return <div>Hello {this.props.name}</div>;
  }
}

function Hello(props: {-name: string}) {
  return <div>Hello {props.name}</div>;
}

const Hello = (props: {|name: string|}) => (
  <div>Hello {props.name}</div>
);
```

```tsx
type Props = {
  name: string;
}
class Hello extends React.Component<Props> {
  render () {
    return <div>Hello {this.props.name}</div>;
  }
}

interface Props {
  name: string;
}
class Hello extends React.Component<Props> {
  render () {
    return <div>Hello {this.props.name}</div>;
  }
}
```

### Correct: the rule accepts this

```jsx
type Props = {
  +name: string,
}
class Hello extends React.Component<Props> {
  render () {
    return <div>Hello {this.props.name}</div>;
  }
}

function Hello(props: {+name: string}) {
  return <div>Hello {props.name}</div>;
}

const Hello = (props: {|+name: string|}) => (
  <div>Hello {props.name}</div>
);
```

```tsx
type Props = {
  readonly name: string;
}
class Hello extends React.Component<Props> {
  render () {
    return <div>Hello {this.props.name}</div>;
  }
}

interface Props {
  readonly name: string;
}
class Hello extends React.Component<Props> {
  render () {
    return <div>Hello {this.props.name}</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/prefer-read-only-props": "error",
    },
  },
];
```

## Related rules

- [sonarjs/prefer-read-only-props](https://lintradar.dev/rules/sonarjs/prefer-read-only-props.md): React props should be read-only
- [react/no-adjacent-inline-elements](https://lintradar.dev/rules/react/no-adjacent-inline-elements.md): Disallow adjacent inline elements not separated by whitespace.
- [react/require-optimization](https://lintradar.dev/rules/react/require-optimization.md): Enforce React components to have a shouldComponentUpdate method
- [react/sort-default-props](https://lintradar.dev/rules/react/sort-default-props.md): Enforce defaultProps declarations alphabetical sorting
- [react/jsx-sort-props](https://lintradar.dev/rules/react/jsx-sort-props.md): Enforce props alphabetical sorting
- [react/sort-prop-types](https://lintradar.dev/rules/react/sort-prop-types.md): Enforce propTypes declarations alphabetical sorting

---

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