清除所有缓存后才会出现此错误。该应用程序是使用javascript和react-native开发的。我们正在使用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有这些线 “@终极版 - 离线/终极版,离线@ ^ 2.3.2”: 版本“2.3.2” 已解决“https://registry.yarnpkg.com/@redux-offline/redux-offline/-/redux-offline-2.3.2.tgz#ecdb324e198bd4aa6b965f651ec589f66c8f2605” 依赖关系: babel-runtime“^ 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>
)
答案 0 :(得分:0)
在gihub上发布了一个与此有关的问题 https://github.com/redux-offline/redux-offline/issues/362#issuecomment-552190934
尝试这种解决方法,
//redux-offline/node_modules/lib/autRehydrate.js:62
function defaultStateReconciler(state, inboundState, reducedState, log) {
var newState = _extends({}, reducedState);
if (typeof inboundState !== 'object') return newState; // add this line.
//...rest
}