Skip to content

noReactPropAssign

Disallow assigning to React component props.

React’s props are assumed to be immutable, and it is considered bad practice to assign to properties of the props object. When using the React Compiler, this is even a hard error.

function Foo(props) {
props.bar = "Hello " + props.bar;
return <div>{props.bar}</div>
}
code-block.jsx:2:2 lint/nursery/noReactPropAssign ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Mutating component props is not allowed.

1 │ function Foo(props) {
> 2 │ props.bar = “Hello ” + props.bar;
^^^^^
3 │
4 │ return <div>{props.bar}</div>

Consider using a local variable instead.

const Foo = function({bar}) {
bar = "Hello " + bar;
return <div>{bar}</div>
}
biome.json
{
"linter": {
"rules": {
"nursery": {
"noReactPropAssign": "error"
}
}
}
}