redux: Odd crash on Expo when minified and in production mode
Prior Issues
- https://stackoverflow.com/questions/73788057/react-native-project-crashing-with-redux-toolkit
- https://stackoverflow.com/questions/74283724/expo-crashes-with-redux-toolkit
- Also have a long discussion here https://forums.expo.dev/t/expo-go-with-react-redux-crashes-on-published-app-but-works-in-local/67949/8
What is the current behavior?
The app crashes immediately. Note this does not occur if the app is not minimized or if in non-production.
Steps to Reproduce
I am unable to make a MVCE to show this.
But this can be recreated in my app https://github.com/trajano/spring-cloud-demo (it’s not a trivial app, but to make it crash I when I add the following to https://github.com/trajano/spring-cloud-demo/blob/rework/expo-app/authenticated-context/AuthenticatedProvider.tsx
import { configureStore } from "@reduxjs/toolkit";
export const store = configureStore({
reducer: {},
});
What is the expected behavior?
Not crash.
Environment Details
"@reduxjs/toolkit": "^1.9.0",
"react-redux": "^8.0.5",
"redux-persist": "^6.0.0",
"expo": "^47.0.6",
"react": "18.1.0",
"react-dom": "18.1.0",
"react-native": "0.70.5",
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (10 by maintainers)
Commits related to this issue
- Remove minified check Fixes https://github.com/reduxjs/redux/issues/4443 — committed to trajano/redux by trajano 2 years ago
- Remove minified check Fixes https://github.com/reduxjs/redux/issues/4443 — committed to trajano/redux by trajano 2 years ago
- Remove minified check (#4454) Co-authored-by: Tim Dorr <timdorr@users.noreply.github.com> Fixes https://github.com/reduxjs/redux/issues/4443 — committed to reduxjs/redux by trajano 2 years ago
Okay, this is finally out in https://github.com/reduxjs/redux/releases/tag/v4.2.1 . Sorry for the delay!
@timdorr @phryneas so tracing back the history of those lines, it dates back to this issue/PR in late 2015:
Worst case I think we’d be okay to remove that warning?
Yes, that’s exactly my point.
Redux Toolkit, the
@reduxjs/toolkit
package, imports methods from theredux
core.That
isCrushed
check is in theredux/src/index.js
module file.It runs as soon as you import anything from the
redux
package.Therefore, yes, importing RTK triggers this crash because importing anything from
redux
runs that check.It’s not RTK that’s the issue. It’s the
redux
index file.