Skip to content

Commit

Permalink
fix(Text): lazy import Troika for Next issue (#1726)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett authored Nov 19, 2023
1 parent f788dbb commit a4da557
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core/Text.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import * as React from 'react'
// @ts-ignore
import { Text as TextMeshImpl, preloadFont } from 'troika-three-text'
import { ReactThreeFiber, useThree } from '@react-three/fiber'
import { suspend } from 'suspend-react'
import { ForwardRefComponent } from '../helpers/ts-utils'
Expand Down Expand Up @@ -54,6 +52,9 @@ export const Text: ForwardRefComponent<Props, any> = /* @__PURE__ */ React.forwa
}: Props,
ref: React.ForwardedRef<any>
) => {
// https://github.com/pmndrs/drei/issues/1725
const { Text: TextMeshImpl, preloadFont } = suspend(async () => import('troika-three-text'), [])

const invalidate = useThree(({ invalidate }) => invalidate)
const [troikaMesh] = React.useState(() => new TextMeshImpl())

Expand Down

1 comment on commit a4da557

@vercel
Copy link

@vercel vercel bot commented on a4da557 Nov 19, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.