We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
astro
1.2.8
None
npm
Stackblitz
Recently issue #4818 was completed allowing more convenient use of the Astro.slots.render function.
Astro.slots.render
However, passing a function as the slot to a component doesn't work in an MDX file.
For example in index.mdx
index.mdx
import List from 'List.astro'; ## Markdown content here <List>{item => <li>{item}</li>}</List>
and in List.astro:
List.astro
--- const items = [ 'item A', 'item B', 'item C', 'item D' ]; --- <ul> {items.map(item => ( <Fragment set:html={Astro.slots.render('default', [item])} /> ))} </ul>
This results in the following output of the List component:
List
item => __vite_ssr_import_5__.jsx(_components.li, { children: item }) item => __vite_ssr_import_5__.jsx(_components.li, { children: item }) item => __vite_ssr_import_5__.jsx(_components.li, { children: item }) item => __vite_ssr_import_5__.jsx(_components.li, { children: item })
It looks as if the toString() value of the function is being returned.
toString()
The desired outcome would be for this to function the same way in MDX files as it does in .astro files.
.astro
https://stackblitz.com/edit/github-lwwufa?file=src%2Fcomponents%2FList.astro,src%2Fpages%2Findex.mdx&on=stackblitz
The text was updated successfully, but these errors were encountered:
Thanks! This seems pretty important, the JSX interop isn't handling slots-as-functions.
Sorry, something went wrong.
Exciting! Thanks all
bluwy
Successfully merging a pull request may close this issue.
What version of
astro
are you using?1.2.8
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
npm
What operating system are you using?
Stackblitz
Describe the Bug
Recently issue #4818 was completed allowing more convenient use of the
Astro.slots.render
function.However, passing a function as the slot to a component doesn't work in an MDX file.
For example in
index.mdx
and in
List.astro
:This results in the following output of the
List
component:It looks as if the
toString()
value of the function is being returned.The desired outcome would be for this to function the same way in MDX files as it does in
.astro
files.Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-lwwufa?file=src%2Fcomponents%2FList.astro,src%2Fpages%2Findex.mdx&on=stackblitz
Participation
The text was updated successfully, but these errors were encountered: