Can't find variable: BigInt in expo (React native)

Hi
I am new to Dfinity and building an application in expo (React native)+typescript. I am trying to do a simple call to internet identity (https://identity.ic0.app), but I get this error in the very first step:
ReferenceError: Can’t find variable: BigInt

Any ideas? Here i the code I have. ultimately my question is, how can I use internet identity in a react native app? Can I use simple http calls?

import { AuthClient } from "@dfinity/auth-client";
export const login = async() => {
    const authClient = await AuthClient.create();
}

React Native use JScore as javascript engine. Which does not support BigInt natively

1 Like

I understand. Any polyfills or workarounds that has been tested?

See my answer here: Making HTTP calls from mobile apps - #21 by jzxchiang

1 Like

Actually, I think the latest iOS’s JSC has BigInt. But Android doesn’t AFAIK.

1 Like

It sounds like there’s a polyfill for Android here:

if (typeof BigInt === 'undefined') global.BigInt = require('big-integer')
1 Like

And if it turns out that BigInt is untenable, I’m open to abstracting the codebase to a Nat64 interface that can accept implementations other than BigInt to improve compatibility

2 Likes

I tried this. for BigInt adding this to the top of my code does not work(At least for expo) and it still givs the same error. I had to add this to the @dfinity module files directly, which would probabely break on each update would be nice to have it added in main branch, unless there is a reason not to.
I added it to this file:
…\node_modules \ @dfinity\agent\lib\cjs\agent\http\transforms.js

For some reason I am blocked from posting the whole solution and could not post what worked for me. So I put it here:

[github.com/functionland/photos/issues/59#issuecomment-880370283]

From all responses here, and the helpful insights in this topic I gathered it for expo(react -native)

I use this solution:

/**
 * Polify BigInt.toJSON for react-native
 * @returns {number}
 */
BigInt.prototype.toJSON = function () {
  return Number(this.toString());
};

if (typeof BigInt === "undefined") global.BigInt = require("big-integer");

React Native (including Expo) supports BigInt now! We’re also going to be replacing the BLS verification soon, so we’ll finally have a simple React Native example ready to go

1 Like