reactotron
reactotron copied to clipboard
Can't push to arrays in `reactotron-core-client`
Error when using the latest beta release and upgrading React Native.

Steps to reproduce the issue.
- Checkout to https://github.com/infinitered/ignite/pull/2377
- Checkout to https://github.com/infinitered/reactotron/pull/1288
- Update this metro config in
ignite/boilerplate/metro.config.js
- Run
npx zx scripts/install-workspace-packages-in-target.mjs ~/Code/ignite/boilerplate/
from reactotron repo - Run
yarn start
andyarn ios
in ignite/boilerplate repo
Context
Tried getting around this by updating the property
But this caused another issue where non-core plugins weren't getting initialized correctly like in reactotron-mst.
Seems like that mutating class properties causes some funky business with prototypes: https://stackoverflow.com/questions/57037585/why-we-cannot-add-a-new-property-to-an-object-constructor-the-same-way-we-add-a
There seems to be one other stack overflow article with this exact error: https://stackoverflow.com/questions/74581572/pushing-an-object-to-an-array-react-native-firestore
Tried pairing with ChatGPT on this, seems to be something about mutating references to properties in a class? https://sharegpt.com/c/rzXf15z
So it turns out that Hermes cannot handle Javascript classes:
This seems to be handled by babel by metro-react-native-babel-preset
Babel does have a plugin to handle classes: https://github.com/facebook/metro/blob/ac3adced45a6ca32286dda9e9470eab6eb4218bf/packages/metro-react-native-babel-preset/src/configs/main.js#L76
Which appears to make properties read only: Playground
But I fed this minified code into Hermes, and it seems to work 🤷