我刚刚在this other question中看到了这段代码,我不明白它是如何工作的:
let Parent = () => (
"
我理解这样的事情:
let Parent = ({api}) => (
但从未见过{foo => < Bar bar = {bar} />}之前的渲染,
有人能帮助我理解这个吗?
最佳答案
组件可以访问使用子prop的子元素.如果函数是作为子函数给出的,则组件可以调用此函数.调用children函数的组件然后可以使用它认为合适的任何参数调用该函数.
例
const Child = props => {
return props.children('test');
};
const Parent = () => (