You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using JSX in an attribute value causes crash with an unhelpful error message.
Example
The following component:
---// List.astro// Is it possible for items to be a list of *rendered* Astro components?const { items } =Astro.props;---
<olclass="mylist">
{items.map((item) => <liclass="mylist-item">{item}</li>)}
</ol>
I want to make the <List> component accepts a list of renderable elements. It will wrap each element with a li.mylist-item, and then wrap the whole thing in ol.mylist.
When I use <List>, I just want to pass the list of items that will go inside the <li>. I don't need to know about the fact that each <li> will have .mylist-item, that's just an implementation detail of <List>.
What version of
@astrojs/compiler
are you using?2.10.3
What package manager are you using?
npm
What operating system are you using?
Linux
Describe the Bug
Using JSX in an attribute value causes crash with an unhelpful error message.
Example
The following component:
When used in the following way:
Causes a crash.
Even just the following use of the
<List>
component would cause a crash:Expected result
Or in the case of the simple example
Notes
Frankly, this works:
This works too:
But this doesn't:
Use case
I want to make the
<List>
component accepts a list of renderable elements. It will wrap each element with ali.mylist-item
, and then wrap the whole thing inol.mylist
.When I use
<List>
, I just want to pass the list of items that will go inside the<li>
. I don't need to know about the fact that each<li>
will have.mylist-item
, that's just an implementation detail of<List>
.Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-yujqde?file=src%2Fpages%2Findex.astro
A more elaborate example
I originally framed this as a question of migrating my React component to Astro on the Discord #general and #support channels:
See also: https://discord.com/channels/830184174198718474/1297291875002355834
The text was updated successfully, but these errors were encountered: