cliff-effects icon indicating copy to clipboard operation
cliff-effects copied to clipboard

Use default exports by default

Open turnerhayes opened this issue 7 years ago • 6 comments

For many components, we are currently using named exports instead of default exports (e.g. import { MyButton } from './MyButton; rather than import MyButton from './MyButton';.) I feel like we should be using default exports for components, with named exports only if it needs to export additional symbols.

This is a somewhat stylistic question; thoughts? Anyone feel strongly otherwise?

turnerhayes avatar Oct 24 '18 22:10 turnerhayes

I'd err more in the opposite direction. I feel that the more consistent we can be, the easier it is for new people getting started. Having both import MyButton from './MyButton'; and import { Button1, Button2 } from './Buttons'; seems like two behaviors to keep track of instead of one.

knod avatar Oct 25 '18 00:10 knod

What are the pros to using default exports?

knod avatar Oct 25 '18 00:10 knod

Mainly terseness, I suppose. I'm not clear why import { Button1, Button2 } from './Buttons'; is the pattern we'd use; I'm inclined to tend towards one component (or at least one exported component) per file, so I would probably tend to use

import Button1 from './Button1'; // or 'Buttons/Button1', if we want to group them together
import Button2 from './Button2';

turnerhayes avatar Oct 25 '18 00:10 turnerhayes

So is this more of a conversation about one abstracted component per file?

knod avatar Oct 25 '18 00:10 knod

I think that plays into it, certainly, but there are components (I believe) that only have one component in a file and still use named exports.

turnerhayes avatar Oct 25 '18 03:10 turnerhayes

Maybe we'll do some real-time talking about this and put those conclusions in here.

knod avatar Oct 25 '18 11:10 knod