You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, when passing the onOpenChange method to a component, the following ESLint warning is triggered:
Avoid referencing unbound methods which may cause unintentional scoping of `this`. If your function does not access `this`, you can annotate it with `this: void`, or consider using an arrow function instead.eslint@typescript-eslint/unbound-method
Expected behavior
The onOpenChange method should be correctly bound, and therefore, no ESLint warnings should be triggered.
This issue arises due to the difference between class member functions and function-valued properties in TypeScript's function type definitions. Class member functions can have this binding issues, whereas function-valued properties do not.
Your environment
Software
Name(s)
Version
Radix Package(s)
@radix-ui/react-collapsible
1.1.2
React
n/a
18
Browser
Assistive tech
Node
n/a
npm/yarn
Operating System
The text was updated successfully, but these errors were encountered:
Bug report
Current Behavior
Currently, when passing the onOpenChange method to a component, the following ESLint warning is triggered:
Expected behavior
The onOpenChange method should be correctly bound, and therefore, no ESLint warnings should be triggered.
Reproducible example
The current code is as follows:
Suggested solution
The issue can be resolved by defining onOpenChange as a function-valued property instead of a class member function:
Additional context
This issue arises due to the difference between class member functions and function-valued properties in TypeScript's function type definitions. Class member functions can have this binding issues, whereas function-valued properties do not.
Your environment
The text was updated successfully, but these errors were encountered: