Skip to content

noJsxPropsBind

  • Rule available since: v2.3.11
  • Diagnostic Category: lint/performance/noJsxPropsBind
  • This rule isn’t recommended, so you need to enable it.
  • This rule doesn’t have a fix.
  • The default severity of this rule is warning.
  • This rule belongs to the following domains:
  • Sources:
biome.json
{
"linter": {
"rules": {
"performance": {
"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/performance/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

<Foo onClick={() => console.log('Hello!')}></Foo>
code-block.jsx:1:15 lint/performance/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

<Foo onClick={function () { console.log('Hello!'); }}></Foo>
code-block.jsx:1:15 lint/performance/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

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