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
- Go to repo
- Clone the project
- Install the dependencies with
npm i - 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.
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 starton aiOS 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
As a workaround you can add the following in your package.json:
Make sure to do
npm install(or use any other package manager e.g. bun) afterwardsWe 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.
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
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.
overridesandresolutionsobject frompackage.jsonnode_modulesHey, 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/utils3.28.1. See https://github.com/adobe/react-spectrum/pull/7885Damn what a headache been troubleshooting this all weekend
Using pnpm this also worked for me
Hi all, this solution worked for me. Create a new polyfill at root location
utils/polyfills.tsand add the following code.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.
This worked for me using
yarnThis worked for me.
I have the same bug. Really frustrating.
Add this to your package.json