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

feat(useLocalStorage): add remove method. (#229) #835

Merged
merged 2 commits into from
Jan 5, 2020

Conversation

suyingtao
Copy link
Contributor

@suyingtao suyingtao commented Dec 13, 2019

Description

Implemented remove method as requested in #229 ;

Reworked a bit implementation of the initialization of useState to make sure not to invoke localStorage.setItem() when localStorage.getItem(key) is null && InitialValue is undefined;

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as before)

Checklist

  • Read the Contributing Guide
  • Perform a code self-review
  • Comment the code, particularly in hard-to-understand areas
  • Add documentation
  • Add hook's story at Storybook
  • Cover changes with tests
  • Ensure the test suite passes (yarn test)
  • Provide 100% tests coverage
  • Make sure code lints (yarn lint). Fix it with yarn lint:fix in case of failure.
  • Make sure types are fine (yarn lint:types).

@suyingtao suyingtao changed the title feat(useLocalStorage): add remove feature. (#229) feat(useLocalStorage): add remove method. (#229) Dec 13, 2019
Copy link
Owner

@streamich streamich left a comment

Choose a reason for hiding this comment

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

Thanks!

What do you think about using undefined for empty value instead of null. If coming from the angle that this hook uses JSON to serialize data and null is a valid JSON value, however undefined in that case would really indicate that the value is missing.

@streamich streamich changed the base branch from master to v14.0 January 5, 2020 08:52
@streamich streamich merged commit 8a6ece1 into streamich:v14.0 Jan 5, 2020
@streamich
Copy link
Owner

🎉 This PR is included in version 15.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

2 participants