-
Notifications
You must be signed in to change notification settings - Fork 93
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
use-raf hook: animation hook for react using requestAnimationFrame #623
base: master
Are you sure you want to change the base?
Conversation
Few questions:
|
any plan to merge this? |
i have several notices on implementation, but I'm ill ATM, will do the review later. |
* @param delay delay in milliseconds after which to start re-rendering component | ||
* @returns number | ||
*/ | ||
export function useRaf(ms = 1e12, delay = 0): number { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ms
should have no default value, also, it is better to rename in to duration
* @param delay delay in milliseconds after which to start re-rendering component | ||
* @returns number | ||
*/ | ||
export function useRaf(ms = 1e12, delay = 0): number { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This hook should have handles to stop and start re-rendenring process, start should apply optional rerender duration.
- In implementation it should reuse
useRafCallback
hook, that is already implemented in this package. elapsed
should useuseSafeState
, since it is updated asynchronously - there is a chance, that component will be unmounted before state update.
Tests don't require |
Please consider streamich/react-use#2215 |
What new hook does?
Checklist