Skip to content

Conversation

@yoanngueny
Copy link

Hello,

When using the Text component of React Drei in a Next.js project, I get this error :
Capture d’écran 2024-02-22 à 15 28 28

I invested the problem, and the Text component uses Troika Text, which uses Typr.
To be honest, I don't know really why there is this error, but by encapsulating the _tdec result in a function, the error is gone.

Can this change could create some side effect?

Dependency order :
https://github.com/pmndrs/drei
https://github.com/protectwise/troika
https://github.com/protectwise/troika/tree/main/packages/troika-three-text
https://github.com/fredli74/Typr.ts

return s;
},
_tdec : typeof window !== 'undefined' && window["TextDecoder"] ? new window["TextDecoder"]() : null,
_tdec : function() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've changed the type of _tdec from TextDecoder | null to a function, so this would certainly break...?

I think maybe a better approach would be to check for TextDecoder global directly?

_tdec : typeof TextDecoder !== 'undefined' ? new TextDecoder() : null

There's probably also some adjustment to be made in troika-three-text where it tries to hack in worker support.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your reply.

I'm gonna open an issue in the Drei repos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants