You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-1
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,7 @@ storeData = async () => {
38
38
39
39
```
40
40
41
-
### Read data
41
+
### Read data
42
42
```jsx
43
43
44
44
getData =async () => {
@@ -54,6 +54,25 @@ getData = async () => {
54
54
55
55
```
56
56
57
+
### useAsyncStorage hook
58
+
59
+
React hooks (introduced in 16.8) allow you to use state and async requests without writing a class. For more info on hooks and how to use them, see [hooks documentation](https://reactjs.org/docs/hooks-intro.html) or the [hooks example](docs/Hooks.md) in this repo.
60
+
61
+
`useAsyncStorage` has no hard-coded dependencies in react hooks, it is just a convenience wrapper around `AsyncStorage`.
Uses the new [hooks api](https://reactjs.org/docs/hooks-intro.html) to give you convenience functions so you can get, set, merge and delete a value for a given key from Async Storage.
506
+
507
+
The `useAsyncStorage` returns an object that exposes all methods that allow you to interact with the stored value.
This just curries the API calls. There can't be a hook like useState until there is an event being dispatched whenever a change is made, like in web browser's LocalStorage.
Like this gist tries to do. It doesn't detect changes made to a key if the change is made without using that setValue function (even if it's the same hook on another component).
2 commit comments
TheDSCPL commentedon Jun 5, 2020
This just curries the API calls. There can't be a hook like
useState
until there is an event being dispatched whenever a change is made, like in web browser'sLocalStorage
.TheDSCPL commentedon Jun 5, 2020
Like this gist tries to do. It doesn't detect changes made to a key if the change is made without using that setValue function (even if it's the same hook on another component).