pinqy520 / mobx-persist

persist mobx stores
MIT License
560 stars 62 forks source link

按照 文档配置,结果报错 #76

Open libbGit opened 5 years ago

libbGit commented 5 years ago

[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: 'Reaction[Reaction@1]' Error: [serializr] Failed to find default schema for undefined

seunlanlege commented 5 years ago

yeah I think this has to do with react-native v0.59.9

r3wt commented 5 years ago

@pinqy520 I have same problem. i am using latest version of mobx with mobx-preact and mobx-persist. this error is being thrown and nothing is being persisted to localstorage

shenopkss commented 5 years ago

Same mistake

[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: 'Reaction[Reaction@1]', [Error: [serializr] expected modelSchema, got undefined]
- node_modules/expo/build/environment/muteWarnings.fx.js:27:24 in error
- node_modules/mobx/lib/mobx.module.js:1723:26 in reportExceptionInDerivation
- node_modules/mobx/lib/mobx.module.js:1702:45 in track
- node_modules/mobx/lib/mobx.module.js:2047:16 in reactionRunner
- node_modules/mobx/lib/mobx.module.js:2035:26 in <unknown>
- node_modules/mobx/lib/mobx.module.js:1660:20 in runReaction
- node_modules/mobx/lib/mobx.module.js:1797:12 in runReactionsHelper
- node_modules/mobx/lib/mobx.module.js:1775:47 in reactionScheduler
- node_modules/mobx/lib/mobx.module.js:1804:84 in <unknown>
- node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:18527:14 in batchedUpdates$1
- node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:2611:31 in batchedUpdates
- node_modules/mobx/lib/mobx.module.js:1804:49 in reactionScheduler
- node_modules/mobx/lib/mobx.module.js:1780:22 in runReactions
- node_modules/mobx/lib/mobx.module.js:1644:24 in schedule
- node_modules/mobx/lib/mobx.module.js:2059:4 in reaction
- node_modules/mobx-persist/lib/index.js:47:24 in hydrate
* src/app.component.tsx:26:8 in <unknown>
- node_modules/metro/src/lib/polyfills/require.js:331:6 in loadModuleImplementation
* App.ts:1:0 in <unknown>
- node_modules/metro/src/lib/polyfills/require.js:331:6 in loadModuleImplementation
- node_modules/expo/AppEntry.js:4:0 in <unknown>
- node_modules/metro/src/lib/polyfills/require.js:331:6 in loadModuleImplementation
- node_modules/metro/src/lib/polyfills/require.js:197:45 in guardedLoadModule
* null:null in global code

package.json

"dependencies": {
    "@eva-design/eva": "^1.0.1",
    "ethers": "^4.0.33",
    "expo": "^33.0.6",
    "expo-analytics": "^1.0.8",
    "expo-camera": "^5.0.1",
    "expo-constants": "^5.0.1",
    "expo-media-library": "^5.0.1",
    "expo-permissions": "^5.0.1",
    "mobx": "^5.13.0",
    "mobx-persist": "^0.4.1",
    "mobx-react": "5.4.4",
    "react": "^16.8.3",
    "react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz",
    "react-native-keyboard-aware-scroll-view": "^0.8.0",
    "react-native-ui-kitten": "^4.1.0",
    "react-navigation": "^3.11.0"
  }
r3wt commented 5 years ago

@shenopkss i was able to solve my issue by changing to @persist to @persist(type). it seems for all non primitives, you must now declare the type when using this latest version of mobx-persist. in my case one was an object and another an array that was causing my issues. changing to @persist('array') and @persist('object') respectively, solved my issue. hope it helps.

r3wt commented 5 years ago

and its stopped working again, and i am not sure why :/

clauderobi commented 8 months ago

Same thing here.

And I am using @persist('number') for my 3 items I want to persist.