Is it possible to auto-import files with webpack or React so that I don't need to `import` every time

39 Views Asked by At

I very often need to write:

<div style={{display:'flex'}}>
  ...
</div>

However, I'd ideally just write:

<Row>
  ...
</Row>

But I don't want to need to import Row from './Row' every time. What's the easiest way to accomplish this?

I'm happy to disable linting for specific variables. Is there something I can do to webpack config to make it accessible to every React file?

1

There are 1 best solutions below

0
Aniruddha On

check webpack provide-plugin, you would need to take your div to separate file & create identifier for that.