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

Return array instead of object for useInterval hook #64

Closed
chattling opened this issue Apr 29, 2019 · 4 comments
Closed

Return array instead of object for useInterval hook #64

chattling opened this issue Apr 29, 2019 · 4 comments
Labels
enhancement New feature or request

Comments

@chattling
Copy link

Is your feature request related to a problem? Please describe.
I would like to be able to give my own names for start and stop functions returned by useInterval hook. It is possible to use object renaming like { start: myStartFunc } with current implementation, however it would be more inline with react hooks to have them returned as array for easier renaming.

Describe the solution you'd like
Return start, stop, intervalId in array instead of in object.

Describe alternatives you've considered
See above

Additional context
N/A

@imbhargav5
Copy link
Owner

Sounds good to me!

We should make it return an array to support array destructuring while maintaining backward compatibility with object destructuring.

Would love it if you can send a PR!

@imbhargav5 imbhargav5 added the enhancement New feature or request label Apr 30, 2019
@chattling
Copy link
Author

I know how to change it by returning array instead of object, but I can't think of way to make it backward compatible without creating whole new hook.
Also I don't feel comfortable opening PR, as I never done it before..

@imbhargav5
Copy link
Owner

It's fine if you are new to it and it's difficult. But you can use my repo as a playground for a PR. I don't mind if it's not the best PR. Most of mine aren't. It's not a compulsion though. :)

@imbhargav5
Copy link
Owner

It's coming in an upcoming release.

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

No branches or pull requests

2 participants