14islands / r3f-scroll-rig

A react-three-fiber scroll-rig for syncing 3D meshes and DOM elements.
MIT License
720 stars 36 forks source link

Error with `r3f-scroll-rig` Components in Turborepo: "Cannot read properties of null (reading 'xr')" #45

Closed pleodigital closed 2 weeks ago

pleodigital commented 2 months ago

Hello,

I'm working on a Turborepo project with the following structure:

Within my ui package, I have several components that utilize r3f-scroll-rig components. After importing them into my apps, everything seems to work fine. However, while testing my apps with PageSpeed or Lighthouse, the websites break and return the following error:

Cannot read properties of null (reading 'xr')

I was able to reproduce this error on several occasions on my local machine using those tools. Initially, the error was accompanied by a "webGL context loss" error, but I can no longer reproduce the entire error scenario locally.

Any ideas on what might be causing this or how to resolve it?

Turborepo Version: 1.12.4

Libraries:

ffdead commented 2 months ago

Hi @pleodigital - we don't call xr anywhere in this library.

Are you sure it's not a @react-three-fiber: issue?

pleodigital commented 2 months ago

Well, I'm not entirely sure, but I assumed that the issue is related to this package because, while testing, the error happened when I was using GlobalCanvas, whereas it did not occur with the regular Canvas from react-three-fiber.