What would an "acceptable-looking" import look like?

May 29, 2019

A user on Reddit is concerned that the following import statement can be too long if more components are imported:

import { Button, Paper, TextField, Stepper, Step, StepLabel, StepContent } from '@material-ui/core'

He wonders which of the following are better:

import { Button,
} from '@material-ui/core'


import Stepper from '@material-ui/core/Stepper';
import Step from '@material-ui/core/Step';
import StepLabel from '@material-ui/core/StepLabel';
import StepContent from '@material-ui/core/StepContent';

In this case, I think the first is better because you don’t need to repeatedly write import package-name from @material-ui/core/package-name for every single import. Less tedium is always a good thing.

Get post updates via email