TypeScript, get prop types for meshStandardMaterial
#2068
-
I'd like to replace the type BoxProps = {
// TODO: Replace this `any` with the prop type for `meshStandardMaterial`
materialProps?: any
}
const Box = ({ props }: BoxProps) => (
<mesh>
<boxBufferGeometry />
<meshStandardMaterial {...props.materialProps} />
</mesh>
)
// This should trigger type hinting and not cause any typescript errors:
const BlueBox = () => <Box materialProps={{ color: 'blue' }} /> |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I figured this out while writing the question, but I thought I'd still ask and answer for people having the same question. Maybe someone else has a better solution? I used type BoxProps = {
materialProps?: JSX.IntrinsicElements['meshStandardMaterial']
}
const Box = (props: BoxProps) => (
<mesh>
<boxBufferGeometry />
<meshStandardMaterial {...props.materialProps} />
</mesh>
)
// This should trigger type hinting and not cause any typescript errors:
const BlueBox = () => <Box materialProps={{ color: 'blue' }} /> EDIT: POSSIBLY BETTER SOLUTION vinayakvivek offered the solution (below) of using |
Beta Was this translation helpful? Give feedback.
I figured this out while writing the question, but I thought I'd still ask and answer for people having the same question. Maybe someone else has a better solution?
I used
JSX.IntrinsicElements['meshStandardMaterial']
:EDIT: POSSIBLY BETTER SOLUTION
vinayakvivek offered the solution (below) of using
MeshStandardMaterialProps
. UnlikeJSX…