How to do it...

Let's say that you have a Drawer component with a few items in it. You also have an AppBar component with a menu button and a title. The menu button should toggle the visibility of the drawer, and clicking on a drawer item should update the title in the AppBar. Here's the code to do it:

import React, { useState, Fragment } from 'react';import { withStyles } from '@material-ui/core/styles';import AppBar from '@material-ui/core/AppBar';import Toolbar from '@material-ui/core/Toolbar';import Typography from '@material-ui/core/Typography';import Button from '@material-ui/core/Button';import Drawer from '@material-ui/core/Drawer';import List from '@material-ui/core/List';import ListItem from '@material-ui/core/ListItem';import ListItemIcon ...

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.