I’d answer the original question…
> Is there an error in the examples? You have
const mesh = useRef()
...
<mesh ref={mesh} ...
> You'll be rendering an undefined element (before the ref has a chance to attach).
…as follows:
1. On that last line, <mesh> is just a regular element[0].
2. Ref assignment makes this element’s instance accessible within component code[1] under a constant, here coincidentally (and confusingly, I must say) named “mesh”. The constant could’ve been named anything else, like “el”, and the example would work exactly the same way:
const el = useRef()
...
<mesh ref={el} ...
3. How come the constant in the original example does not shadow the equivalently named built-in JSX element? Well, there is a convention/hard-coded rule in React/JSX/TSX where it simply would not resolve lowercase identifiers to custom components. If we change “mesh” to “Mesh” in the original example,
then the app would attempt to use the ref constant as a (malformed) custom component, and predictably throw.
[0] https://www.w3.org/TR/2016/CR-SVG2-20160915/shapes.html#Mesh...
[1] https://reactjs.org/docs/refs-and-the-dom.html#refs-and-func...