-
-
Notifications
You must be signed in to change notification settings - Fork 115
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 React-compatible update function to useMMKVStorage hook #98
Comments
Hey @SaltedBlowfish do you plan to work on sending a PR with this feature? |
@SaltedBlowfish I have added support for setter. test it out on master so I can release the next version |
@ammarahm-ed Sorry for the delay. I did plan on working on this but I'm traveling right now and ended up not having the time. I didn't realize you'd get to it so quickly. I won't be able to test it out for another week or so though. |
@ammarahm-ed I ended up pulling your changes and resolving conflicts with my fork. See my PR here: #103 I have not tested it yet (like I said I'm traveling right now). |
#98 Add React-compatible update function to useMMKVStorage hook
Shipped in v0.5.9 |
See #13 (comment) for the original mention that led to this issue being opened
Currently, the
useMMKVStorage
hook doesn't reflect the expectation of the "setter" portion of the React built-in state hooks. It's not documented that it should, but would provide convenience for developers implementing this package...Ideally, we would be able to have a state change with a previous value provided, similarly to the
React.useState
hook for making sure value writes are happening without overwriting previous states:React's API
RN MMKV's API
To support this, the
setValue
function above must support a callback as a parameter for dynamically computing the next state.Usage example:
The text was updated successfully, but these errors were encountered: