5

The code in app.js file with import statements for react redux is created to display a header with a text called "Tech stack".

App.js

import React from 'react';
import { View } from 'react-native';
import { Header } from './components/common';
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import reducers from './reducers';


const App = () => {
  return(
    <Provider store={createStore(reducers)}>
      <View>
        <Header headerText="Tech Stack" />
      </View>
    </Provider>
  );
};

export default App;

This is the index file

index.js

import { AppRegistry } from 'react-native';
import App from './src/App';


AppRegistry.registerComponent(tech_stack, () => App);

While running this on the terminal, it throws a error saying unable to resolve module 'react-redux'.

4
  • did u try restarting the JS bundle ? Commented Jul 10, 2019 at 5:37
  • Have you added react-redux to your project dependences via either npm install or yarn add? Commented Jul 10, 2019 at 5:38
  • i installed using npm install --save redux.the entry for redux is there in the package.json file Commented Jul 10, 2019 at 5:42
  • @NabeelK how to do that? Commented Jul 10, 2019 at 5:43

5 Answers 5

3

Close the JS bundle(a terminal starts when you run app for first time) and rerun it using the command react-native start from the project path. Basically, you need to rerun the JS bundle after every package installation.

Sign up to request clarification or add additional context in comments.

4 Comments

have u install redux ? if not install and try again
i first installed using npm install --save redux and then run did npm start and then react-native run-ios.Same error persists.
then pls do npm install react-redux --save and restart JS bundle
i did react-native start reset-cache ,but it is taking long time.is it normal?
3

Install 'react-redux' by using

npm install --save react-redux

if you not installed it. By seeing your comment as you mentioned that you installed redux only. Then restart the JS bundle by using

react-native start --reset-cache

5 Comments

react-redux is this package also present in package.json or it is installed completely ?
then may be restart the js bundle would be help did you try it ?
how to restart it?
go to terminal where it is running press ctrl+c to stop the running bundle. then in new terminal go to app main folder of project and use this command react-native start --reset-cache
Perfect... Saved my lots of time.
2

I've faced this issue just now. actually, Our (you and I) main issue is naming the global state folder name is redux and the bundler falls in a conflict because there is a folder inside node_modules that name is redux too.

In fact, the main issue is this line:

import { createStore } from 'redux';

I renamed the resux stuffs folder to reduxStore instead of redux and then everything works properly.

2 Comments

@Vikash, no, sorry for my bad explanation, I mean the folder name that redux stuffs are in it, I renamed it from redux to reduxStore.
Make sure your source files are not located in a folder by the name redux. Once I renamed the folder to something else, the error disappeared.
1

This error occurs because you do not have Redux-Thunk middleware installed on your application. To install run:

npm install redux-thunk

Then, restart your application:

react-native start

More information: https://github.com/reduxjs/redux-thunk

Comments

0

I just ran into this problem and solved it by installing redux in addition to react-redux. Apparently, react-redux requires it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.