Skip to content
Advertisement

TypeError: (0, _$$_REQUIRE(_dependencyMap[0], “redux”).createStore) is not a function react-native

I’m new in redux I’m trying to connect redux with react native when I set all and In App.js i add <provider store={store}> it display me that error: TypeError: (0, _$$_REQUIRE(_dependencyMap[0], “redux”).createStore) is not a function.

App.js

import { Counter } from './assets/counter';
import { Provider } from 'react-redux';
import {store} from './assets/store/store'
const App= (props) => {
  return (
    <View style={{flex:1}}>
      <Provider store={store} >
        <Counter/>
      </Provider>
    </View>
  );
};


export default App;

cunter.js

export const Counter = (props) =>{
    return(
        <View style={{flex:1,justifyContent:'center', alignItems:'center'}} >
            <Button title="Add Inc"  />
            <Text>Counter</Text>
            <Button title="Add Dec"  />
        </View>
    )
}

store.js

import {createStore} from 'redux'
import {mainReducer} from './reducers'


export const store = createStore(mainReducer)

reducer.js

import {ADDITION, SUBTRACTION} from './actionType'

const initialState = {
    counter:0
}

export const mainReducer=(state=initialState, action)=>{
    switch (action.type) {
        case ADDITION:
            return {...state, counter:state.counter+1}
        case SUBTRACTION:
            return {...state, counter:state.counter-1}
    
        default:
            return state
    }
}

package.json

  "dependencies": {
    "react": "17.0.1",
    "react-native": "0.64.2",
    "react-redux": "^7.2.4",
    "redux": "^4.1.1"
  },

Answer

i have same problem but its solved and i just want to share.. its all happen because “npx react-native init Redux” well i try to create another react-native init with different name and move all folder from old one that i named it “Redux” then its all running normal.. so do not try to create folder or event project name with same modul thats we installed via NPM.. hope its help and enjoy your day.. thank you..

Advertisement