Are JSX elements in global scope? #1875
-
Not really a feature request or a bug... just a question. I've been using ThreeJS for a year, React since the alpha, and figured I'd give this a shot. I'm a bit confused about the JSX elements. I never see them imported into the module in any of the examples. Are they just attached to the global scope? This seems like a bad practice, if not an anti-pattern. Sure, it's convenient, but doesn't this mean that all JSX elements are in memory at all times? Even if not, explicitly importing what you need seems far more intuitive. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
When rendering inside |
Beta Was this translation helpful? Give feedback.
-
These elements are primitives, just like react-three-fiber is a renderer and it reconciles I've written more about how this works here, if you're asking about the JavaScript implementation. |
Beta Was this translation helpful? Give feedback.
These elements are primitives, just like
<div />
and<button />
for the DOM andreact-dom
.react-three-fiber is a renderer and it reconciles
<mesh />
intonew THREE.Mesh()
. This is done dynamically -- there's no wrapper or anything suspended in memory for it to do so.I've written more about how this works here, if you're asking about the JavaScript implementation.