The problem is that you are returning one button from function cell formatting.
Use this:
cellButton(cell, row, enumObject, rowIndex) { let uiItems = []; for(var group in this.state.jsonFromDatabase){ if (this.state.jsonFromDatabase[group].id !== row.id){ uiItems.push(<button style={{ backgroundColor: "blue"}} type="button" onClick={() => this.onClickGroupSelected(cell, row, rowIndex)}> Process the group </button>) }else{ uiItems.push(<button style={{ backgroundColor: "red" }} type="button" onClick={() => this.onClickGroupToUpdate(cell, row, rowIndex)}> Update the group </button>) } } return uiItems; }
or use map , for example:
cellButton(cell, row, enumObject, rowIndex) { return this.state.jsonFromDatabase.map((group, i) => { if (group.id !== row.id){ return <button style={{ backgroundColor: "blue"}} type="button" onClick={() => this.onClickGroupSelected(cell, row, rowIndex)}> Process the group </button> }else{ return <button style={{ backgroundColor: "red" }} type="button" onClick={() => this.onClickGroupToUpdate(cell, row, rowIndex)}> Update the group </button> } }) }
source share