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-timout: Add parameters for callback function #2721

Merged
merged 5 commits into from Oct 18, 2022
Merged

[@mantine/hooks] use-timout: Add parameters for callback function #2721

merged 5 commits into from Oct 18, 2022

Conversation

linardsblk
Copy link
Contributor

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.

@@ -1,16 +1,16 @@
import { useRef, useEffect } from 'react';

export function useTimeout(
fn: () => void,
Copy link
Member

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?

Copy link
Contributor Author

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,
Copy link
Member

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.

Copy link
Contributor Author

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.

@rtivital rtivital merged commit 19f0960 into mantinedev:dev Oct 18, 2022
@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