React-redux: mapStateToProps not triggered running RN on android emulator

Created on 10 Dec 2018  路  6Comments  路  Source: reduxjs/react-redux

Do you want to request a _feature_ or report a _bug_?

Possibly a bug

What is the current behavior?

When I run this code: https://codesandbox.io/s/8l2wk98qpl
On the android studio emulator (Pixel 2 API 28) using react-native run-android, the mapStateToProps never gets triggered, so the screen fails to re-render. The state does seem to be updated under the hood (using redux-persist and forcing the app to reload shows me the new screen)

What is the expected behavior?

The code works properly in the sandbox, as well as on my physical device, so this seems to be an interaction with react-redux and the AVD

Which versions of Redux, and which browser and OS are affected by this issue? Did this work in previous versions of Redux?

Windows 10, Android Studio 3.2.1, jdk 1.8.0_191
"react-redux": "^6.0.0",
"redux": "^4.0.1",
"react": "^16.6.3",
"react-native": "0.57.4",
Have not tested any other versions

All 6 comments

Hmm. That seems like it'd be awfully hard to reproduce, and I would find it surprising if there's anything in React-Redux itself causing this issue.

Can you check to see what happens if you use React-Redux 5.1.1? Also, can you provide steps for reproducing the exact development environment where you're seeing this?

npm install --save [email protected]
react-native run-android
Loading dependency graph, done.
error: bundling failed: Error: Unable to resolve module `./components/Context` from '...'

Is this symptomatic of an issue with my environment?

My environment is set up following the instructions for 'Building Projects with Native Code' on Windows+Android here:
https://facebook.github.io/react-native/docs/getting-started.html

I opened the issue with Google here too, given that it works everywhere but their emulator I do suspect the root cause is somewhere on their end: https://issuetracker.google.com/issues/120779844

React-Redux v5 does not have a ./components/Context file, so that suggests you've got a weird mixture of both versions running at the same time somehow.

I was able to resolve this by starting a new project, clearly something was screwed up in my project dir.

For people who will encounter the './components/Context` issue in the future:
For me the issue was revert of the react-redux from 6.0.1 to 5.1.1, which left a cache files of the 6.0.1 that were used by npm install or metro bundler even though that not suppose to happen :(

npm cache cleanup, delete node modules folder, restart and npm install solved it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

a-koka picture a-koka  路  3Comments

sajaddp picture sajaddp  路  3Comments

nainardev picture nainardev  路  3Comments

winterbe picture winterbe  路  3Comments

psbanka picture psbanka  路  4Comments