【发布时间】:2019-06-04 21:10:50
【问题描述】:
我正在寻找一种将组件数组传递给选项卡组件的道具的方法。只是想知道这是否可能。
所以我需要创建一个组件来缩短材质 ui 的 tabbing 方法,但是我找不到将组件数组作为 prop 传递的方法,以便在该组件上呈现它。
这是我的代码示例:
<FullWidthTab
components = [<Component1/>, <Component2/>] //this is where components renders
menuLabels = ['Menu1', 'Menu2'] //this is where title render
/>
我像这样将它们映射到我的代码上,我使用了 lodash map 方法:
map(components, component=>{
<TabContainer>{component}</TabContainer>
}
但它会返回这个。 警告:react-swipeable-view:提供的孩子之一无效:null。 我们期待一个有效的 React 元素
当我 console.log 它返回的组件时:
{$$typeof: Symbol(react.element), type: ƒ, key: null, ref: null, props: {…}} Object 需要帮助
我希望它可以渲染组件。
【问题讨论】:
-
你有解决办法吗?
标签: reactjs material-ui