Skip to content

Support changing onAction prop #59

@filiptdz

Description

@filiptdz

The timers ignore changes to onAction, therefore when it changes the timeout calls the first version of the function that was passed, and not the latest. This is what causes issues like #46 and #54. I imagine the solution might not be that straightforward, since resetting the timer every time this prop changes would be unwanted, but perhaps a good solution would be to use a ref to the onAction inside the timeout callback, and updating that ref with the value of onAction on every render. This way, a stale closure isn't called when the timeout ends.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions