作为一个好例子,考虑这样的react组件:
const MyComponent = (props) => {}
在上述组件中,我们可以访问以下道具的子代:
const MyComponent = ({count, value, ...rest}) => {}
使用... rest,我们也可以有未列出的孩子。
我的问题,是否可以使用和不使用道具来访问所有孩子?像这样的东西:
const MyComponent = ({count, value } = props) => { // I know this is wrong, it's just an example
return <>{props.count} {value} {props.someThingNotListed} </>
// getting able to access to destructed child direclty or by using props if we want
}