I'm developing a CRNA application, however, the store connection is not working and I'm receiving the above error when creating the store.
"Undefined is not an object (evaluating action.type)
Searching for similar problems, I got to this question, which is a reducer being called while passed to the createStore
function, which is not my case.
And this one, which is related to AnalyticsTracker
called before an async dispatcher, also not my case.
Here's the minimum code to reproduce.
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>
);
}
}
store.js
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import reducer from './reducer';
// Here the error happens
export default createStore(reducer, applyMiddleware(thunk));
reducer.js
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;
}
I have tried a few changes in my code, i.e: removing the middlewares.
Any idea why is it happening? Am I missing something?