-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
[Bug] removeItem will break useMMKVStorage hook #252
Comments
@mydesweb Let me check. Did this happen when you were debugging with chrome? |
@ammarahm-ed I don't use any debugger, just running my code in DEV mode on Android device & Emulator, I manage to reproduce this issue each time.. |
@mydesweb I have tested on android emulator and a real device. I am doing same as what you told me and I cannot reproduce this. On clicking a button in app: console.log(storage.getString('oneKey'), storage.getInt('anotherKey')); // Check values.
storage.setString('oneKey', 'stringValue');
storage.setInt('anotherKey', 1);
storage.removeItem('anotherKey');
|
@ammarahm-ed you are right, I omitted something, checked again my code and you have to obtain
at this point |
basically after using |
@mydesweb So you are saying that after removing a value from storage and restarting the app, all And without using |
@ammarahm-ed yes, this is the case. you don't have to restart the app if the hook is consumed only after the key is removed. If you call the hook first and after you remove the value you have to restart the app or call again the hook. |
@mydesweb So all values are there but the hook is not updated? Your initial issue was that all values from storage are removed/deleted? Is that still true or no? |
@ammarahm-ed the hook will start to return undefined or defaultValue if is set for other keys wich are not removed. If it still not clear I will provide a complete code in few hours. |
@mydesweb An example would be helpful. |
@ammarahm-ed please run the code below. Certainly we will not consume the MMKV this way but wanted to keep code simple.
|
@mydesweb I think I found the bug. Will fix this asap |
All fixed in v0.7.4 |
Describe the bug
I just try to remove one item for a given key but after running
removeItem
method all other item keys are removed. This is not happening immediately, only after the app is restarted.To Reproduce
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Only one item should be removed
Platform Information:
Additional context
If I don't run
removeItem
everything is working as expected.The text was updated successfully, but these errors were encountered: