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
Description of the issue
Passing an object with date to useMMKVStorage will return the string representation of the date on subsequent renders:
// inside componentconst[value,setValue]=useMMKVStorage<{date: Date}>(storage,{date: newDate()});// first renders while value isn't retrieved from cold storageconsole.log(typeofvalue);// object// after restarting the appconsole.log(typeofvalue);// string
The useMMKVStorage hook works in isolation from the main storage library. Hence if we do use a reviver function it would be at initialization. Or another option is to pass it into the hook but use it to fix already parsed object. In your case it's the date. Something like this:
Description of the issue
Passing an object with date to
useMMKVStorage
will return the string representation of the date on subsequent renders:Example of parsing without reviver:
react-native-mmkv-storage/src/indexer/maps.ts
Line 44 in 01edd65
Expected behavior
object/map storage should have a reviver function parameter which is then passed to JSON.parse
PS.: I can probably fix it, just creating this issue confirming this is not working as intended
The text was updated successfully, but these errors were encountered: