Can't import MeshProps as shown in readme #1172
-
Hei! I am trying to get this party started using typescript and found my first tiny hurdles. Some of these aren't really a big deal and common sense can help, but I still found them interesting.
Another interesting thing I noticed is that after installing the types for three my IDE gets annoyed with me, saying I'm missing a ton of required attributes. Here's 1/20th of the messages I get:
Update: I also noticed that hmr seems a bit wonky when I change the hierarchy. Based on the demo in the README I wrap the two boxes in in a group and get an error saying: "TypeError: Cannot read property 'rotation' of null" coming from the useFrame(). |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
three-types is new, three's dropped types. i've added a mention of this in the docs. as for jsx type, they must be missing from the main export? @joshuaellis as for hmr, not sure, normally you must check refs in typescript since they can be null. i don't know exactly what hmr does to the component, i guess it invalidates all refs and the useframe goes out of sync one frame and catches back up. that would only happen on hot reload, not for prop updates and checking it will fix it. i can look into that if there's anything the reconciler does to help us detect hot reload. |
Beta Was this translation helpful? Give feedback.
-
MeshProps sounds like it was exported from ReactThreeFiber. However what would make more sense if you use JSX.IntrinsicElements[‘mesh’] IMO. THREE has never exported MeshProps.... re installing @types/three, you can thank someone else for that 😅👀 |
Beta Was this translation helpful? Give feedback.
-
@RWOverdijk hmr is fixed #1178 |
Beta Was this translation helpful? Give feedback.
three-types is new, three's dropped types. i've added a mention of this in the docs. as for jsx type, they must be missing from the main export? @joshuaellis
as for hmr, not sure, normally you must check refs in typescript since they can be null. i don't know exactly what hmr does to the component, i guess it invalidates all refs and the useframe goes out of sync one frame and catches back up. that would only happen on hot reload, not for prop updates and checking it will fix it. i can look into that if there's anything the reconciler does to help us detect hot reload.