How to do it...

Let's say that your application needs to display a dialog with a Select component for selecting an item. The options for the select are populated from an API endpoint, so you need to handle the latency between the user opening the dialog and the API data arriving. Here's an example that shows one way to do this:

import React, { Fragment, useState } from 'react';import { makeStyles } from '@material-ui/styles';import Button from '@material-ui/core/Button';import DialogTitle from '@material-ui/core/DialogTitle';import DialogContent from '@material-ui/core/DialogContent';import DialogContentText from '@material-ui/core/DialogContentText';import DialogActions from '@material-ui/core/DialogActions';import Dialog from '@material-ui/core/Dialog'; ...

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.