I have a series of icon buttons in which most properties are common. The only thing that changes is the icon type and onClick functions. Currently, I am implementing it in the following manner:
const listOfButtons = <div>
<IconButton
flat
icon={<AddIcon />}
onClick={doSomething}
primary
/>
<IconButton
flat
icon={<EditIcon />}
isDisabled
primary
/>
<IconButton
flat
icon={<TrashIcon />}
isDisabled
primary
/>
<IconButton
flat
icon={<RefreshIcon />}
primary
/>
</div>;
I want to try to reduce the redundancy of the code and try to define only one IconButton object and pass different icons and different onClicks to it as in future there might be more icon buttons. I am stuck as to how to assign onclick to a particular icon button. Is there an efficient way of defining multiple icon buttons and assigning icons and onclicks than what I have done above? Please help!