0

I am fairly advanced in React and Javascript overall, but I cannot find the right words to form my question so I will use examples (Would appreciate for someone to fill in the gaps, who is more eloquent in the field).

So when I do import { useRef, useState } from "react"; I obviously get the functions defined as constants without having to access the object first React.useRef => useRef

Then there's const { camera, size, gl: { domElement }} = useThree() So how would I be able to access size, which contains width and height (size.width/size.height), without having to access the size object first? I would prefer to just get width returned without defining another const first.

Is there a documentation on all of that, that I missed?

M -
  • 26,908
  • 11
  • 49
  • 81
  • Yes, thank you now I know what to look for and that I was trying to ask about "ES6 Destructuring". Helps me write shorter code! Thanks a lot. – SarenSabertooth Dec 17 '20 at 20:52

1 Answers1

0

Realized the solution myself, but I would still be curious about other use cases and the proper documentation.

const { camera, size: { width, height }, gl: { domElement }} = useThree()