reactotron icon indicating copy to clipboard operation
reactotron copied to clipboard

Reactotron does not support `BigInt()`

Open markrickert opened this issue 1 year ago • 7 comments

A community member raised an issue in the reactotron channel that the library doesn't support BigInt().

Indeed, it does not.

<Button
  text="BigInt(0)"
  onPress={() => {
    console.log(BigInt(0))
  }}
/>

image

markrickert avatar Feb 06 '24 23:02 markrickert

Hey, this change seems to cause issue in React Native Android

I'm getting this (non-blocking) error "Property 'BigInt' doesn't exist". I was able to fix it by installing the big-integer package and adding this code to my entrypoint

if (typeof BigInt === 'undefined') {
  global.BigInt = require('big-integer');
}
image

(Btw I'm using a relatively old version of RN ~> 0.67.5)

mcreusot avatar Feb 20 '24 16:02 mcreusot

@mcreusot I just found this thread where it's stated that BigInt support was added to react native in 0.70.

I'll spin up an app with an older version and try and ship a permanent fix for this issue. Thanks for bringing it to my attention!

markrickert avatar Feb 21 '24 15:02 markrickert

Hello. I have the same issue. React native 0.73.4 "reactotron-react-native": "^5.1.3", I have tried this followed troubleshooting but it didn't help adb reverse tcp:9090 tcp:9090 How to solve that? On IOS app works, on android I builds successfully, but I see the same error screen ReferenceError: Can't find variable: BigInt

* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.`

lossen avatar Feb 22 '24 15:02 lossen

I encountered this same issue as well while following the Reactotron Quick Start guide when shifting over from Flipper.

my package.json:

{
    ...
    "dependencies": {
        ...
        "react-native": 0.72.6,
        ...
    },
    "devDependencies": {
        ...
        "reactotron-react-native": "^5.1.4",
        "reactotron-redux": "^3.1.9",
        ...
    },
    ...
}

Since I was switching over from Flipper on a react-native project, I just decided to go with downgrading the dependencies.

Based on https://github.com/infinitered/reactotron/pull/1437/commits/846c8ca281b154cc05054dd3c57c0b30967257a0, the BigInt reference in the serialize.ts of reactotron-core-client was added since v2.9.0 of reactotron-core-client to address the JSON.stringify issue, so I downgraded from there and my package.json now looks like this:

{
    ...
    "dependencies": {
        ...
        "react-native": 0.72.6,
        ...
    },
    "devDependencies": {
        ...
        "reactotron-react-native": "5.0.5",
        "reactotron-redux": "3.1.7",
        "reactotron-core-client": "2.8.13",
        ...
    },
    ...
}

I was hoping to get away with this without adding the additional big-integer dependency. Perhaps a possible fix to address this in reactotron-core-client could be to add optional-chaining to the fix so that it only targets systems with BigInt?

BigInt?.prototype.toJSON = function() { return this.toString() }

hliejun avatar Mar 28 '24 10:03 hliejun

Still reproduce for React Native v0.72.4 (only for Android)

"reactotron-react-native": "^5.1.6",

vasylnahuliak avatar Apr 24 '24 14:04 vasylnahuliak

same issue on "react-native": "0.71.11",

LouisMuriuki avatar Jul 24 '24 11:07 LouisMuriuki

Inspired by @hliejun I came up with the following patch that solves the issue for me. However I have no Idea if it might break things (I didn't try to debug with android / reactotron yet):

reactotron-core-client+2.9.3.patch

c-goettert avatar Jul 30 '24 10:07 c-goettert