I’m trying to create a TabSet in React with dynamically created Tabs.
Here’s my simple example:
When I run it, I get an error.
I found that without the <tabs> node, the TabSet renders without errors, so I tried this version:
But I still get an error when creating the TabSet. What should I do?
PS: The error occurs if this.templatesDS.cacheData = [].
Here’s my simple example:
Code:
<TabSet ID="templatesTabSet" width="100%" height="*" paneMargin="0">
{isTabs &&
<tabs>
{this.templatesDS.cacheData.map((templates, index) => (
<Tab
title={templates[CONSTANT.TITLE]}
key={index}
templates={templates}
pane={this.createTabPane(templates)}
/>
))}
</tabs>
}
</TabSet>
I found that without the <tabs> node, the TabSet renders without errors, so I tried this version:
Code:
<TabSet ID="templatesTabSet" width="100%" height="*" paneMargin="0">
{(this.templatesDS.cacheData && this.templatesDS.cacheData.length > 0) &&
<tabs>
{this.templatesDS.cacheData.map((templates, index) => (
<Tab
title={templates[CONSTANT.TITLE]}
key={index}
templates={templates}
pane={this.createTabPane(templates)}
/>
))}
</tabs>
}
</TabSet>
PS: The error occurs if this.templatesDS.cacheData = [].
Comment