Skip to content Skip to sidebar Skip to footer

React Native Redux CreateStore Error:undefined Is Not An Object(evaluating 'action.type')

I'm use Redux with ReactNative,I'd like to create a store with reducer And,I got error below, point to line 'switch (action.type)' in function switchToTab() in reducer.js undefine

Solution 1:

You dont call the reducer when you create the store. createStore accepts a reducer function as its first argument.

import { createStore } from 'redux';
import { switchToTab } from './reducer.js'

export default class MainPage extends Component {
    constructor(props) {
    super(props);
    this.state = {
        index:0
    };

    let store = createStore(switchToTab); // dont call this here, just pass it
}

Post a Comment for "React Native Redux CreateStore Error:undefined Is Not An Object(evaluating 'action.type')"