It depends on how the modules are exported.
In the @material-ui
example, there will be an index.js
file located at the root containing named exports for other files. This isn't a requirement, so not all packages let you do this.
Take a look at the material-ui source code. You can see here that this file exports all of the icons using named exports.
However, if you go to a specific icon module, you will see it uses a default export.
This is why you can do it more than one way.
As for the @iconify/icons-mdi
, I do not know if they contain this index file, so you may or may not be able to import both ways. I don't have experience with this library like I do with material-ui, but the documentation I found did not reference named imports anywhere.
You can read more about the differences between named and default imports in here.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…