- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 145
Open
Labels
bugA verified and reproducible bug.A verified and reproducible bug.triageHas not been reviewed yet and should not be worked on.Has not been reviewed yet and should not be worked on.
Description
What happened?
const { activate } = useIdleTimer(config);The above will throw:
@typescript-eslint/unbound-method: 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.
According to this stackoverflow post, it's because there's a meaningful difference between:
type IIdleTimer = {
activate(): bool;
}
// and
type IIdleTimer = {
activate: () => bool;
}which is that the former is typed as a function() definition and carries the this weirdness, where the latter is not.
Reproduction Steps
See aboveRelevant log output
N/AScreenshots or Additional Context
No response
Module Version
5.7.2
What browsers are you seeing the problem on? Select all that apply.
No response
What devices are you seeing the problem on?
No response
Verification
- I have checked for existing closed issues and discussions.To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
jonaldinger, aarondill and sabriele
Metadata
Metadata
Assignees
Labels
bugA verified and reproducible bug.A verified and reproducible bug.triageHas not been reviewed yet and should not be worked on.Has not been reviewed yet and should not be worked on.
Projects
Milestone
Relationships
Development
Select code repository
Activity
SupremeTechnopriest commentedon Jul 27, 2023
Nice catch! Out of curiosity, is this popping up for you because you are using class components?
reify-tanner-stirrat commentedon Jul 28, 2023
Nope, normal functional components defined as arrow functions. To be honest I don't understand enough about typescript to understand why it's complaining about this.
SupremeTechnopriest commentedon Jul 28, 2023
Are you using
this? No worries I'll look into it.reify-tanner-stirrat commentedon Jul 28, 2023
Nope. I also opened #361 to fix it.