首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >undefined不是对象(计算'Object.keys(inboundState)')

undefined不是对象(计算'Object.keys(inboundState)')
EN

Stack Overflow用户
提问于 2018-05-12 07:35:28
回答 1查看 1.8K关注 0票数 3

此错误仅在清除所有缓存后发生。该应用程序是使用javascript和react-native开发的。我们使用的世博会有一个iOS模拟器,一个真正的iPhone和一个安卓平板电脑。当应用程序重新加载时,程序启动时没有任何故障。

这是来自iOS的错误

代码语言:javascript
复制
undefined is not an object(evaluating 'Object.keys(inboundState)')

消息中列出的其他信息如下

代码语言:javascript
复制
defaultStateReconciller
autoRehydrate.js:66:14

dispatch
createStore.js:178:36

这就是它在Android请求的值不是对象的键上的表现方式。

消息中列出的其他信息如下

代码语言:javascript
复制
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”依赖关系:babel-运行时"^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

代码语言:javascript
复制
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>
    )

EN

回答 1

Stack Overflow用户

发布于 2020-01-07 15:13:53

在gihub上发布了一个关于此https://github.com/redux-offline/redux-offline/issues/362#issuecomment-552190934的问题

尝试此解决方法,

代码语言:javascript
复制
//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 
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50301517

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档