callstack / super-app-showcase

Monorepository template for super app development with React Native and Re.Pack
MIT License
382 stars 63 forks source link

Error integrating redux-toolkit: Unhandled JS Exception #90

Closed aw-capgemini closed 1 month ago

aw-capgemini commented 1 month ago

Description

I encountered an error while integrating redux-toolkit with the super-app-showcase. The error message is:

Unhandled JS Exception: Cannot read property 'increment' of undefined TypeError: Cannot read property 'increment' of undefined at ./features/counter/counterSlice.ts

Simulator Screenshot - iPhone SE (3rd generation) - 2024-05-28 at 14 05 08

This occurs when trying to use the increment action from the counter slice. The same code works fine in a normal React Native app but fails in the super-app-showcase app.

Steps to Reproduce:

Set up redux-toolkit in the project. Define a counter slice with increment action. Attempt to dispatch the increment action in a component.

Expected Behavior: The increment action should be dispatched correctly without errors.

Actual Behavior: The application crashes with the error mentioned above.

Reproducible Demo

https://github.com/aw-capgemini/super-app-showcase/tree/redux-toolkit

jbroma commented 1 month ago

Hey, have you checked this? https://github.com/callstack/repack/issues/500#issuecomment-1991677970

this is 99% a resolution issue that was already solved once before. I can see that the demo is using Re.Pack 3.4.0, so all of the steps from the issue need to be applied in order to get this to work.

aw-capgemini commented 1 month ago

Hi @jbroma,

I managed to get it to work by following the resolution provided! Thank you for your response.