So I have seen people using different ways to declare a function. However, I saw one way that I did not quite understand. The sample code is shown as below:
type Props = {
name: string,
age: number
}
const someFunction = ({
name,
age
}: Props) => {
return (
// Do something here
)
}
So I know this code here is first creating a Props object with name and age. The part that I do not get is the part where it shows ({name, age}: Props)
. I am guessing it is a parameter mapping the state to the props, but I am not sure. Can anyone explain this please?