gluestack-ui: Error Expo Project - ReferenceError: Property 'FinalizationRegistry' doesn't exist

Description

Installing gluestack on a fresh expo project triggers this error. Both providers (OverlayProvider and ToastProvider) trigger it. When commenting them out, the error does not occur.

CodeSandbox/Snack link

https://github.com/vinifraga/gluestack-error

Steps to reproduce

  1. Go to repo
  2. Clone the project
  3. Install the dependencies with npm i
  4. Run with npm run start

gluestack-ui Version

v2

Platform

  • Expo
  • React Native CLI
  • Next
  • Web
  • Android
  • iOS

Other Platform

No response

Additional Information

I’ve only tested on the iOS environment, don’t know if it’s also happening on Android.

Image

My steps were:

  • Create an Expo project with npx create-expo-app
  • Initialize Gluestack v2 with npx gluestack-ui init
  • Run the project with npm run start on a iOS Simulator (Expo GO).

The same error happened when tried to run a project created with the npm create gluestack@latest command.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 14
  • Comments: 44

Most upvoted comments

As a workaround you can add the following in your package.json:

"overrides": {
	"@react-aria/utils": "3.27.0"
},

Make sure to do npm install (or use any other package manager e.g. bun) afterwards

We talked to one of the devs of react-aria and react-spectrum and they will be releasing a patch soon. No idea about any specific timeline. For the time being please use the hack mentioned above to override the package version.

As a workaround you can add the following in your package.json:

"overrides": {
	"@react-aria/utils": "3.27.0"
},

Make sure to do npm install (or use any other package manager e.g. bun) afterwards

This worked for me using yarn

"resolutions": {
	  "@react-aria/utils": "3.27.0"
  }

Should I use “overrides” or “resolutions”? Do you know what’s the difference?

depends on what package manager you are using. for npm and bun you should use overrides, for yarn you should use resolutions

@PrinzKenny1 https://github.com/gluestack/gluestack-ui/issues/2771#issuecomment-2707688773

As a workaround you can add the following in your package.json:

"overrides": {
	"@react-aria/utils": "3.27.0"
},

This worked for me! Thanks!

Closing this issue.

If someone still faces this issue, please re-open.

If someone is still having issues.

You can try this.

  • remove the overrides and resolutions object from package.json
  • delete node_modules
  • delete the lock file
  • run the install command

Hey, sorry about this issue. We looked at MDN’s compatibility data for FinalizationRegistry, which unfortunately doesn’t include React Native, so we missed that it wasn’t supported there.

We released a patch to fix this issue: @react-aria/utils 3.28.1. See https://github.com/adobe/react-spectrum/pull/7885

Damn what a headache been troubleshooting this all weekend

Using pnpm this also worked for me

  "pnpm": {
    "overrides": {
      "@react-aria/utils": "3.27.0"
    }
  }

Hi all, this solution worked for me. Create a new polyfill at root location utils/polyfills.ts and add the following code.

const globalAny: any = global;
if (typeof globalAny.FinalizationRegistry === 'undefined') {
  globalAny.FinalizationRegistry = class {
    register() {}
    unregister() {}
  };
}

Import this file in the top app/_layout.tsx import '../utils/polyfills';

Now re-run the application and reload if it’s already running in a simulator or Expo-Go if it’s in an actual device.

Image

As a workaround you can add the following in your package.json:

"overrides": {
	"@react-aria/utils": "3.27.0"
},

Make sure to do npm install (or use any other package manager e.g. bun) afterwards

This worked for me using yarn

"resolutions": {
	  "@react-aria/utils": "3.27.0"
  }

This worked for me.

As a workaround you can add the following in your package.json:

"overrides": {
	"@react-aria/utils": "3.27.0"
},

Make sure to do npm install (or use any other package manager e.g. bun) afterwards

I have the same bug. Really frustrating.

Add this to your package.json

"overrides": {
    "@gluestack-ui/provider": "^0.1.13",
    "@react-aria/utils": "3.27.0",
    "@react-native-aria/interactions": "0.2.15",
    "@react-native-aria/checkbox": "0.2.9",
    "@react-aria/checkbox": "3.14.0",
    "@react-aria/focus": "3.16.0",
    "@react-aria/overlays": "3.22.0",
    "@react-aria/interactions": "3.21.0"
  },