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(hooks): Add useLocalStorage hook and documentation #109

Merged
merged 7 commits into from
Aug 10, 2022

Conversation

mturley
Copy link
Collaborator

@mturley mturley commented Aug 9, 2022

This PR adds the useLocalStorage hook, based on the implementation in crane-ui-plugin here, which is itself a simplification of the LocalStorageContext from forklift-ui here.

It has been enhanced since the crane-ui-plugin version to use JSON.stringify() and TypeScript generics so that any JSON-serializable value can be persistent instead of just strings. It also has error handling added and the addition of a check for window to be defined so that it won't break components in a server-rendering or unit testing environment.

I also upgraded tslib as part of this PR so we can use [...spread] syntax in examples.

@mturley mturley requested a review from a team August 9, 2022 21:14
@konveyor-preview-bot
Copy link

🚀 Deployed Storybook Preview: http://konveyor-lib-ui-pr-109-preview.surge.sh

@codecov
Copy link

codecov bot commented Aug 9, 2022

Codecov Report

Merging #109 (0fc4786) into main (4f6ff1b) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##              main      #109   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines           19        19           
  Branches         5         5           
=========================================
  Hits            19        19           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@mturley mturley force-pushed the use-local-storage branch from 6e99595 to f178535 Compare August 9, 2022 21:19
@mturley mturley merged commit ddbaef0 into migtools:main Aug 10, 2022
@mturley mturley deleted the use-local-storage branch August 10, 2022 15:35
@konveyor-release-bot
Copy link

🎉 This PR is included in version 8.3.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.

3 participants