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-timout: Add parameters for callback function #2721
Conversation
@@ -1,16 +1,16 @@ | |||
import { useRef, useEffect } from 'react'; | |||
|
|||
export function useTimeout( | |||
fn: () => void, |
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.
Why fn was renamed to callback?
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.
It was called callback in docs so I thought I change it to be consistant. callback seemed more descriptive than fn to me. Feel free to comment/change if you'd like to see it reversed.
@@ -1,16 +1,16 @@ | |||
import { useRef, useEffect } from 'react'; | |||
|
|||
export function useTimeout( | |||
fn: () => void, | |||
callback: (callbackParams?: any) => void, |
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.
What if you want to pass more than one argument? Change type to allow any amount of arguments.
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.
Pushed changes based on your feedback.
Thanks! |
Issue discussed here - https://discord.com/channels/854810300876062770/1029643292431892491/1029643292431892491
As of now, setTimeout callback function is called without any parameters. I found it to be useful when these parameters can be pased from start() function.