-
Notifications
You must be signed in to change notification settings - Fork 468
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
Feature/use async storage #22
Feature/use async storage #22
Conversation
Hi @kadikraman, thanks for your work, looks great! I'm going to hold off a bit before merging this one with few notes to consider:
I'm going to assign issue and this PR to you. Sounds good? |
Hi @krizzu - added a specific example and separated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look great, thank You!
I left few comments to check out, let me know what you think.
docs/API.md
Outdated
Uses the new [hooks api](https://reactjs.org/docs/hooks-intro.html) to give you convenience functions to get, set, merge and delete a value from a location. | ||
|
||
The `useAsyncStorage` returns an object that exposes all all the methods that allow you to interact with the stored value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all all
typo here
docs/API.md
Outdated
1. On mount, we read the value at `@storage_key` and save it to the state under `value` | ||
2. When pressing on "update value", a new string gets generated, saved to async storage, and to the component state | ||
3. Try refreshing the app with `cmd + R` - you'll see that the last value is still being read from async storage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe "Try to reload your app", to keep it platform-agnostic :)
docs/API.md
Outdated
## `useAsyncStorage` | ||
|
||
Uses the new [hooks api](https://reactjs.org/docs/hooks-intro.html) to give you convenience functions to get, set, merge and delete a value from a location. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about changing from a location
to from Async Storage, for given key
or something similar? Just to point that this custom hook is Async Storage key-specific.
@krizzu thanks for the feedback - updated. |
Thanks a lot! |
🎉 This PR is included in version 1.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Could anyone elaborate, what's the point of this "hook"? It's not even a hook, really, since it doesn't use built-in hooks under the hood. |
To be honest, having a second look at this, I get your point. I definitely see it's clearly missing a 'hook' functionality. I'll add this to "clean up" list, to make this one actually use hooks API. Thanks @vkurchatkin |
Yeah, my bad, it doesn't use the built in hooks under the hood. It's just a partially applied function that has a hook-like api. Maybe a better idea would be to use |
I've opened an issue for further discussion |
Fixes #16
Adding a
useAsyncStorage
hook to be used with React >=16.7.