-
Notifications
You must be signed in to change notification settings - Fork 727
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Text with react-native TypeError: element.setAttribute is not a function #19
Comments
Running into this issue on my react-native project as well. Is there a work-around while we wait for this to resolved? |
+1 |
Also having this issue attempting to use OrbitControls. |
any updates on this issue? Also getting this on my react-native project. |
+1 |
1 similar comment
+1 |
i suspect that troika is using dom related stuff underneath maybe? @lojjic as for orbitcontrols @thomasjgrady none of three's controls run in RN. expo has its own ports. same issue, threes controls depend on web api. |
Troika-three-text and its dependencies don't use the DOM at all, much less That said, if this error happens simply by importing Text, then it's clear there's something going on that's making it try to import |
oh right, i remember this issue. if this is a distinct problem im honestly scratching my head import React, { Children, forwardRef, useMemo, useLayoutEffect, useState } from 'react'
import { Text as TextMeshImpl } from 'troika-three-text'
import { ReactThreeFiber, useThree } from 'react-three-fiber'
type Props = JSX.IntrinsicElements['mesh'] & {
children: React.ReactNode
color?: ReactThreeFiber.Color
fontSize?: number
maxWidth?: number
lineHeight?: number
letterSpacing?: number
textAlign?: 'left' | 'right' | 'center' | 'justify'
font?: string
anchorX?: number | 'left' | 'center' | 'right'
anchorY?: number | 'top' | 'top-baseline' | 'middle' | 'bottom-baseline' | 'bottom'
clipRect?: [number, number, number, number]
depthOffset?: number
overflowWrap?: 'normal' | 'break-word'
whiteSpace?: 'normal' | 'overflowWrap' | 'overflowWrap'
outlineWidth?: number | string
outlineColor?: ReactThreeFiber.Color
debugSDF?: boolean
onSync?: (troika: TextMeshImpl) => void
}
export const Text = forwardRef(({ anchorX = 'center', anchorY = 'middle', children, onSync, ...props }: Props, ref) => {
const { invalidate } = useThree()
const [troikaMesh] = useState(() => new TextMeshImpl())
const [nodes, text] = useMemo(() => {
let n: React.ReactNode[] = []
let t = ''
Children.forEach(children, (child) => {
if (typeof child === 'string') {
t += child
} else {
n.push(child)
}
})
return [n, t]
}, [children])
useLayoutEffect(
() =>
void troikaMesh.sync(() => {
invalidate()
if (onSync) onSync(troikaMesh)
})
)
return (
<primitive
dispose={undefined}
object={troikaMesh}
ref={ref}
text={text}
anchorX={anchorX}
anchorY={anchorY}
{...props}
>
{nodes}
</primitive>
)
}) |
Having the same issue. Anybody working on this? Impossible to get anything work on a device. |
This is due to Because We can think also about separating a |
released in v2.3.0-beta.1, please track in #221 |
I got similary issue with this, could any body help? |
Hi there,
When using the Text component in a react-native app (with expo-gl) I get the following error:
Simply importing the package seem to trigger the error.
The text was updated successfully, but these errors were encountered: