Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[@mantine/hooks] use-timeout: Memoize clear and start functions #3801

Merged
merged 3 commits into from
Mar 21, 2023

Conversation

lgaspari
Copy link
Contributor

Solves #3789

  1. Wrap both clear() and start() functions with the useCallback() hook so that they won't change across re-renders (unless they have to, e.g. start() depends on delay).
  2. Add missing test case for autoInvoke effect when delay changes.
  3. Correct autoInvoke effect dependencies to include clear() and start() as well as options.autoInvoke.

As far as I could check, the above changes shouldn't affect anyone using this hook. However, there's a separate commit (see point 3) that changes autoInvoke effect dependencies and I'm not 100% sure of relying on options.autoInvoke. People shouldn't really change that setting after the first render, so I'd think it's safe, but I'm open to suggestions.

@rtivital rtivital merged commit 416f393 into mantinedev:dev Mar 21, 2023
@rtivital
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants