Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native - (0, _redux.combineReducers) is not a function

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.

like image 981
PeeJee Avatar asked Feb 07 '26 23:02

PeeJee


1 Answers

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.

like image 59
Colin Ricardo Avatar answered Feb 12 '26 06:02

Colin Ricardo