noJsxPropsBind
Summary
Section titled “Summary”- Rule available since:
v2.3.11 - Diagnostic Category:
lint/nursery/noJsxPropsBind - This rule doesn’t have a fix.
- The default severity of this rule is information.
- This rule belongs to the following domains:
- Sources:
- Inspired from
react/jsx-no-bind
- Inspired from
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noJsxPropsBind": "error" } } }}Description
Section titled “Description”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.
Invalid
Section titled “Invalid”<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>Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.