quarrant/mobx-persist-store

[Bug] React Native - ReferenceError: Storage is not defined

Closed this issue · 4 comments

Hi,
In v1.0.1 I'm getting an unhandled exception when trying to use makePersistable.
It seems like there's a missing import for Storage in isStorageControllerLike ?

Possible Unhandled Promise Rejection (id: 0): ReferenceError: Storage is not defined ReferenceError: Storage is not defined at Object.exports.isStorageControllerLike

I don't see that issue myself. Can you recreate it in https://codesandbox.io/ and paste the example here.

Hey, thanks for the quick reply and for working on this package!
I can't recreate it in codesandbox as I'm trying to create a PoC with React Native.
If you look at utils.ts, it seems that the recently added check for Storage is missing an import.

if (value instanceof Storage) {

I will look into this. I haven't used this package in React Native. Storage is native to JavaScript but might not be supported in React Native.

@quarrant do you have experience in React Native and want to look at this also with me?

@codeBelt
Checking if Storage is available seems to behave as expected in RN.
const isStorageAvailable = typeof Storage !== 'undefined';
...
if (isStorageAvailable && value instanceof Storage) {...}