Skip to content

noJsxPropsBind

biome.json
{
"linter": {
"rules": {
"nursery": {
"noJsxPropsBind": "error"
}
}
}
}

Disallow .bind(), arrow functions, or function expressions in JSX props

Using .bind() or creating a function inline in props creates a new function on every render, changing identity and defeating memoisation, which may cause unnecessary rerenders.

<Foo onClick={this._handleClick.bind(this)}></Foo>
code-block.jsx:1:15 lint/nursery/noJsxPropsBind ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This function will be recreated on every render. Pass stable function references as props to avoid unnecessary rerenders.

> 1 │ <Foo onClick={this._handleClick.bind(this)}></Foo>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

JSX props should not use .bind()

Consider extracting the function or wrapping it in useCallback

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

<Foo onClick={() => console.log('Hello!')}></Foo>
code-block.jsx:1:15 lint/nursery/noJsxPropsBind ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This function will be recreated on every render. Pass stable function references as props to avoid unnecessary rerenders.

> 1 │ <Foo onClick={() => console.log(‘Hello!’)}></Foo>
^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

JSX props should not use arrow functions

Consider extracting the function or wrapping it in useCallback

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

<Foo onClick={function () { console.log('Hello!'); }}></Foo>
code-block.jsx:1:15 lint/nursery/noJsxPropsBind ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This function will be recreated on every render. Pass stable function references as props to avoid unnecessary rerenders.

> 1 │ <Foo onClick={function () { console.log(‘Hello!’); }}></Foo>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

JSX props should not use function expressions

Consider extracting the function or wrapping it in useCallback

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

<Foo onClick={this._handleClick}></Foo>