【发布时间】:2020-01-07 15:13:52
【问题描述】:
此错误仅在清除所有缓存后发生。该应用程序是使用 javascript 和 react-native 开发的。我们将 Expo 与 iOS 模拟器、真正的 iPhone 和 Android 平板电脑一起使用。当应用重新加载时,程序会顺利启动。
这是来自 iOS 的错误
undefined is not an object(evaluating 'Object.keys(inboundState)')
与消息一起列出的其他信息如下
defaultStateReconciller
autoRehydrate.js:66:14
dispatch
createStore.js:178:36
这就是它在 Android 上的表现方式 请求的键值不是对象。
与消息一起列出的其他信息如下
defaultStateReconciller
dispatch
createStore.js:190:3
yarn.lock 有这些行 "@redux-offline/redux-offline@^2.3.2": 版本“2.3.2” 已解决“https://registry.yarnpkg.com/@redux-offline/redux-offline/-/redux-offline-2.3.2.tgz#ecdb324e198bd4aa6b965f651ec589f66c8f2605” 依赖项: 通天塔运行时“^6.26.0” redux-persist "^4.5.0"
redux-persist@^4.5.0: 版本“4.10.2” 已解决“https://registry.yarnpkg.com/redux-persist/-/redux-persist-4.10.2.tgz#8efdb16cfe882c521a78a6d0bfdfef2437f49f96” 依赖项: json-stringify-safe "^5.0.1" lodash "^4.17.4" lodash-es "^4.17.4"
redux-persist@^5.9.1: 版本“5.9.1” 已解决“https://registry.yarnpkg.com/redux-persist/-/redux-persist-5.9.1.tgz#83bd4abd526ef768f63fceee338fa9d8ed6552d6”
App.js
import { createStore, combineReducers, compose } from 'redux'
import { offline } from '@redux-offline/redux-offline'
import offlineConfig from '@redux-offline/redux-offline/lib/defaults'
import storage from 'redux-persist/lib/storage'
import { persistStore, persistReducer } from 'redux-persist'
const persistConfig = {
key: 'root',
storage
}
const persistedReducer = persistReducer(persistConfig, appReducer)
offlineConfig.effect = (effect, action) => {
return fetchApi(effect.endpoint, effect.payload ? effect.payload : null,
effect.method ? effect.method : null, effect.headers ? effect.headers : null)
}
export const store = createStore(
persistedReducer,
[],
compose(
offline(offlineConfig)
)
)
return (
<Provider store={store}>
<PersistGate loading={null} persistor={persistor}>
<Initialize />
<Root>
<RootStack />
</Root>
</PersistGate>
</Provider>
)
【问题讨论】:
-
“只有在清除所有缓存后才会出现此错误”... 好的,所以您正在尝试在加载之前使用某些东西。在清除缓存之前,它是从缓存中读取的(快速),但是在您清除缓存之后,它需要从网络中获取它,因此在您使用它时还没有准备好使用。
-
听起来你在用
redux-persist,可以分享配置相关的redux-persist吗? -
redux-persist 正在使用中。我已经包含了 yarn.lock 中对 redux-persist 的引用以及 App.js 中的配置,谢谢
-
有什么解决办法吗?我也面临同样的问题