1

hello is is possible to create alias for ref :

const [ref, {top, right, bottom, left }] = useMeasure();

i tried using : and as and it didn't work

const [ref : name, {top, right, bottom, left }] = useMeasure();
const [ref as name, {top, right, bottom, left }] = useMeasure();

1 Answer 1

2

When you use array destructuring assignment you are assigning the name right then and there. If you want the first array element "ref" to be named name, then destructure it as such.

const [name, {top, right, bottom, left }] = useMeasure();

See Array Destructuring for more details.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.