How it works...

Let's look at the markup that's used to render each list item:

<ListItem key={index} button>  <ListItemIcon>    <Icon />  </ListItemIcon>  <ListItemText primary={item.name} />  <ListItemSecondaryAction>    <IconButton      onClick={onBluetoothClick(index, 'bluetooth')}    >      <MaybeBluetoothIcon bluetooth={item.bluetooth} />    </IconButton>  </ListItemSecondaryAction></ListItem>

The ListItemSecondaryAction component is used as a container for any controls in your list item. In this example, an IconButton is used as the control. It shows a different icon depending on the state of the item, using the MaybeBluetoothIcon component. The onBluetoothClick() function is used to return the event handler function for the item. Let's take a look at this function: ...

Get React Material-UI Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.