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

Add reset util to useList #654

Merged
merged 1 commit into from
Oct 7, 2019
Merged

Add reset util to useList #654

merged 1 commit into from
Oct 7, 2019

Conversation

wardoost
Copy link
Contributor

@wardoost wardoost commented Oct 7, 2019

useMap has a reset callback that resets the state to its initial value which I was missing in useList so I added it here. I also added tests and updated the docs and story.

I also added memoization of the callback utils and aded tests for this.

Last but not least I was thinking about removing clear because you mostly need to be able to clear the array when you're starting with an empty array in the first place. The reset callback proposed here results in the same behaviour as it resets to the initial (default) value []. I haven't implemented it as I wanted to know what others think

@wardoost wardoost requested a review from Belco90 October 7, 2019 09:44
Copy link
Contributor

@Belco90 Belco90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with the PR. About clear method, I like this kind of shortcuts even if they don't look so used, but 1) it's handy and 2) removing it would imply breaking changes, so I think it's better to leave it for now.

@wardoost wardoost merged commit 9ea3548 into master Oct 7, 2019
streamich pushed a commit that referenced this pull request Oct 7, 2019
# [12.3.0](v12.2.3...v12.3.0) (2019-10-07)

### Features

* reset util callback for useList ([#654](#654)) ([9ea3548](9ea3548))
@streamich
Copy link
Owner

🎉 This PR is included in version 12.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@wardoost wardoost deleted the useList-reset branch October 7, 2019 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants