How to do it...

Let's say that you need to render a menu with more options than can reasonably be rendered at once on the screen. Also, one of the menu items can be in a selected state. Here's some code that shows how to deal with this situation:

import React, { Fragment, useState } from 'react';import { makeStyles } from '@material-ui/styles';import IconButton from '@material-ui/core/IconButton';import Menu from '@material-ui/core/Menu';import MenuItem from '@material-ui/core/MenuItem';import MenuIcon from '@material-ui/icons/Menu';const items = [  'None',  'Atria',  'Callisto',  'Dione',  'Ganymede',  'Hangouts Call',  'Luna',  'Oberon',  'Phobos',  'Pyxis',  'Sedna',  'Titania',  'Triton',  'Umbriel'];const ITEM_HEIGHT = 48;const useStyles = makeStyles(theme ...

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.