Issue
export default function SoftMount({
children,
child_ref,
real_class_name,
duration,
}) {
return <div/>
}
usage:
<SoftMount unexpected_prop={"some_value"} />
Inside of <SoftMount />
, how do I access unexpected_prop
?
Solution
You can capture all remaining properties using the "rest parameters" sytax (...variable_name
)
export default function SoftMount({
children,
child_ref,
real_class_name,
duration,
...other_props // This will collect all other props not destructured
}) {
console.log(other_props.unexpected_prop); // "some_value"
return <div/>
}
Answered By - Unlucky
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.