一旦我刷新页面并通过从状态中获取相同的道具重新加载相同的道具,我就会收到上述错误。我无法找到为什么在重新加载页面时发生这种情况,在第一次加载页面加载正常。
const Content = (props) => {
if (props.tabItem.contentList !== undefined) {
return (
<div>
{props.tabItem.contentList.map((tab) => {
if (props.tabItem.currentTab === tab.tabId) {
return (
<div key={props.tabItem.currentTab}>
{tab.content.props.children}
</div>
);
}
})}
</div>
);
}
return (
<div>no record</div>
);
};
My tabItem that saving in the state is like this:-
tabList = [{
tabId: '1',
tabName: 'Test'
isPrimary: true,
},
];
// create new contentList
contentList = [
{
tabId: '1',
content: <div> <Test1Container{...this.props} addTab={this.addTab} /></div>,
},
];
tabData = {
tabList,
currentTab: '1',
contentList,
};
this.props.addTabItem(tabData);
this.props.addTabItem is use to save the state.