Using React.js and Semantic UI React I'd like to dynamically create tabs.
When using a const representing the array of tab objects, this works fine.
const panes = [
{
menuItem: 'Record 1',
render: () => <Tab.Pane>Tab 1 Content</Tab.Pane>
}
]
...
<Tab panes={panes}/>
However, I need these to be dynamically added based on the state variable source:
getPanes() {
return this
.state
.source
.map((source) => [{
menuItem: source.sourceName,
render: () => <Tab.Pane>Tab 1 Content</Tab.Pane>
}])
}
...
<Tab panes={this.getPanes}/>
This results in:
Warning: Failed prop type: Invalid prop `panes` of type `function` supplied to `Tab`, expected an array.