应用程序组件的渲染渲染了 hello 组件或者它到底做了什么?它是 jsx 吗?
Render of app component renders the hello component or what does it exactly do ?Is it jsx?
<App render={
<Hello render={
(bar) => <div>hi</div>
}/>
}></App>
我学过react,没见过这种代码
来自 React 文档:Render Prop in React
The term “render prop” refers to a technique for sharing code between
React components using a prop whose value is a function.
可以简单地把它想象成将 prop
传递给 App
但这次 prop value
是一个组件而不是普通的 data type
(例如数组、字符串、对象等)。
如果您使用过 react-router-dom
库,它使用相同的概念。
<App render={
<Hello render={
(bar) => <div>hi</div>
}/>
}></App>
我学过react,没见过这种代码
来自 React 文档:Render Prop in React
The term “render prop” refers to a technique for sharing code between React components using a prop whose value is a function.
可以简单地把它想象成将 prop
传递给 App
但这次 prop value
是一个组件而不是普通的 data type
(例如数组、字符串、对象等)。
如果您使用过 react-router-dom
库,它使用相同的概念。