Ios 反应本族语:又一个;Undefined不是对象(正在评估action.type)

Ios 反应本族语:又一个;Undefined不是对象(正在评估action.type),ios,react-native,react-redux,create-react-native-app,Ios,React Native,React Redux,Create React Native App,我正在开发一个CRNA应用程序,但是,商店连接不起作用,我在创建商店时收到上述错误 “Undefined不是对象(评估动作.类型) 为了寻找类似的问题,我找到了,这是一个在传递到createStore函数时被调用的reducer,这不是我的情况 这与在异步调度器之前调用的AnalyticsTracker有关,我的情况也不是这样 这是要复制的最小代码 App.js import React from 'react'; import { View, Text } from 'react-na

我正在开发一个CRNA应用程序,但是,商店连接不起作用,我在创建商店时收到上述错误

“Undefined不是对象(评估动作.类型)

为了寻找类似的问题,我找到了,这是一个在传递到
createStore
函数时被调用的reducer,这不是我的情况

这与在异步调度器之前调用的
AnalyticsTracker
有关,我的情况也不是这样

这是要复制的最小代码

App.js

import React from 'react';
import {
  View,
  Text
} from 'react-native'; 
import { Provider } from 'react-redux';
import store from './store';

class App extends React.Component {

  render() {
    return (
      <Provider store={store}>
         <View>
            <Text>Hello</Text>
         </View>
      </Provider>
    );
  }
}
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';

import reducer from './reducer';
// Here the error happens
export default createStore(reducer, applyMiddleware(thunk));
import actionTypes from './action_types';
const initialState = {
}

export default (action, state=initialState) => {
    // This is the top line on stacktrace
    switch (action.type) {
        case actionTypes.MY_ACTION:
            return state;
    }
    return state;
}
reducer.js

import React from 'react';
import {
  View,
  Text
} from 'react-native'; 
import { Provider } from 'react-redux';
import store from './store';

class App extends React.Component {

  render() {
    return (
      <Provider store={store}>
         <View>
            <Text>Hello</Text>
         </View>
      </Provider>
    );
  }
}
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';

import reducer from './reducer';
// Here the error happens
export default createStore(reducer, applyMiddleware(thunk));
import actionTypes from './action_types';
const initialState = {
}

export default (action, state=initialState) => {
    // This is the top line on stacktrace
    switch (action.type) {
        case actionTypes.MY_ACTION:
            return state;
    }
    return state;
}
我在代码中尝试了一些更改,例如:删除中间件


知道为什么会发生这种情况吗?我遗漏了什么吗?

我注意到您的createStore调用是错误的,因为增强子是作为第三个参数传递的。请将其更改为:

const store = createStore(persistedReducer, undefined, applyMiddleware(thunk));
此外,减速器的结构为false。减速器中的第一个参数应该是initialState,后面是作为第二个参数的操作-这就是为什么未定义的不是对象

如Reducers中所述,它必须具有(previousState,action)=>newState的签名,称为reducer函数,并且必须是纯的和可预测的


From:

我注意到您的createStore调用为false,因为增强子作为第三个参数传递。将其更改为:

const store = createStore(persistedReducer, undefined, applyMiddleware(thunk));
此外,减速器的结构为false。减速器中的第一个参数应该是initialState,后面是作为第二个参数的操作-这就是为什么未定义的不是对象

如Reducers中所述,它必须具有(previousState,action)=>newState的签名,称为reducer函数,并且必须是纯的和可预测的


From:

如果您卸下了交换机外壳,是否会删除错误?如果您卸下了交换机外壳,是否会删除错误?