Issue
I'm confused on these different uses of children and why they work. Can anyone explain? Is children a default parameter for react native functions?
const Component = ({
children = <Text>Insert Icon</Text>,
}) => {
return ( {children} );
};
const Component = ({
{children},
}) => {
return ( {children} );
};
Not a problem, just want an explanation
Solution
Is children a default parameter for react native functions?
Yes. You can set default value for parameters in function:
const multiply = (a, b = 1) => {
return a * b;
}
console.log(multiply(5, 2));
// Expected output: 10
console.log(multiply(5));
// Expected output: 5
More info: docs
Answered By - DinhNguyen
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.