I'm currently learning some redux in React Native. But i keep stumbling on one error if i try to combine my reducers in a index.js file.
(0, _redux.combineReducers) is not a function
I watched some tutorials for how to use this and I follow with every step but it's keep coming on my screen.
My App.js looks like this:
import React, { Component } from 'react';
import { Platform, StyleSheet, Text, View } from 'react-native';
import ReduxThunk from 'redux-thunk';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import reducers from './reducers/reducers';
import { Header } from './components/common/Header';
let store = createStore(reducers, applyMiddleware(ReduxThunk));
export default class App extends Component {
render() {
return (
<Provider store={ store }>
<View style={ styles.container }>
<Header title="Tech Stack"/>
</View>
</Provider>
);
}
}
My reducers.js in the folder src/reducers:
console.log('HELLO');
import { combineReducers } from 'redux';
console.log( combineReducers );
import LibraryReducer from './LibraryReducer';
const reducers = combineReducers({
libraries: LibraryReducer
});
export default reducers;
// Fixed the log. When i'm loggin combineReducers i get undefined.
LibraryReducer.js
import data from '../data/LibraryList.json';
export default () => data;
Console errors:
[Error log][1]
data json:
[
{
"id": 0,
"title": "React",
"description": "JS framework"
},
{
"id": 1,
"title": "Vue",
"description": "JS framework"
},
{
"id": 2,
"title": "Angular",
"description": "JS framework"
}
]
package.json
{
"name": "redux",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.6.1",
"react-native": "0.57.5",
"react-redux": "^5.1.1",
"redux": "^4.0.1",
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"babel-jest": "23.6.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.49.2",
"react-test-renderer": "16.6.1"
},
"jest": {
"preset": "react-native"
}
}
THANK YOU ALL for your suggestions!
SOLVED: Started a new project but don't gave it the name redux itself.
It looks like you have the same issue as here.
TLDR: rename the folder you have called redux to something else, wipe your node_modules and reinstall and it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With