#Can any name be used for imported components?

9 messages ยท Page 1 of 1 (latest)

tame mural
#

Can I use any name after import when importing components or must it match the name of the component itself?

Can I do:

---
import Click from './Button.astro';
---

Or must it be:

---
import Button from './Button.astro';
---

Must all component names be capitalized?

lucid crescent
#

you can use any name, I think it's like import default as.

#

Capital letter is not needed for import but needed to be used as Component.

steel agate
#

Overall the name does not really matter but when you try to use the component it might conflict with the already existing things.

Like if you have "import Header from ..." and then try to use <Header></Header> There might be a conflict.

I tend to go with things like "import my_Header from .... " or something of the like

lucid crescent
steel agate
#

I wont edit my comment though. Good info for others ๐Ÿ˜„

lucid crescent
#

all good, this is a discussion.