我有一个像这样的组件
const Component = () => {
return (
<div>
<div className="data1">
{children}
</div>
<div className="data1">
{children2}
</div>
</div>
)
}
我希望在"data1" div中包含Item1和Item2,而在"data2" div中包含其他组件。使用下面的代码,我只有Item1和Item2作为子元素,但不知道如何添加第二个子元素(比如Item3和Item4)。
<Component>
<Item1/>
<Item2/>
</Component>
我需要在应用程序中多次重用组件,因此一个名为children2的返回元素的函数并不是个好主意,因为它们取决于使用该组件的位置而不同。
data1
和data2
? - Kalhan.Toress