I have created my drop down menu , but unfortunately it recieves an duplicated value from the API . I receive certain amount of documents from the BE and some of the are have the same name so in my dropdown i receive a duplication of the names . My code looks like this :
My function
divideItems = () => {
let startIndex = ((parseInt(this.state.activePaginationTab) + 1) * this.state.rowsPerPage) - this.state.rowsPerPage;
let endIndex = (parseInt(this.state.activePaginationTab) + 1) * this.state.rowsPerPage - 1;
let tabItems = [];
for (let i = startIndex; i <= endIndex; i++) {
if (this.state.items[i]) {
tabItems.push(this.state.items[i]);
}
}
this.setState({
tabItems: tabItems
}, () => {
});
My Rendering
<RBS.Dropdown>
<RBS.Dropdown.Toggle id="dropdown-invoice-header">
{translations.type}
</RBS.Dropdown.Toggle>
<RBS.Dropdown.Menu>
{this.state.tabItems.map(item => (
<RBS.Dropdown.Item >{item.documentType}</RBS.Dropdown.Item>
))}
</RBS.Dropdown.Menu>
</RBS.Dropdown>
The result duplicating items in my dropdown menu .
state.tabItems
as well?state.tabItems
also a little bit further .