I have a doubt can any body help me with my doubt or can any one tell me where I can find my answer?
So as we know in object destructing we must use the same property name to destructure. However, in React when we destructure useParams
from react-router-dom we use any random property name. example const {randomName} = useParams()
is this not destructing?
By same property name I meant this:
const person = { name: "jon", age: 32, location: "UK", };
const { name } = person;
const { abc } = person;
console.log(name); // logs - jon
console.log(abc);// logs - undefined
//(since we did not use the same property name as "name".
const { name } = person;
is equivalent toconst name = person.name
. Ifperson
has no nameproperty
,person.name
will as expected returnundefined
and so willconst { name } = person;
, too.