Replies: 2 comments 7 replies
-
Okay, fine. I think I've found the solution. The thing is that I don't know React at all, so the problem in some kind of way wasn't Astro but the way I was handling the component coming from React. I will post what worked for me in case it works for anyone, since there's not much information about using shacdn-ui components that contain children with Astro, all videos and material I've gone through were basic examples of a Button or so, that worked perfectly because they were a single element. You need the original component: popover.tsx and your own component, you can name it as you please: I named mine as the following: Wrappedpopover.tsx:
Now go to whatever .astro file you are working on and call the component:
|
Beta Was this translation helpful? Give feedback.
-
@santvaz I had a doubt, but I am not completely sure about it because its been months now since I have touched Astro framework, my own website is written in Astro (uses shadcn) and I don't remember what I did few months back. I wanted to ask by any chance did you happen to pass <Popover client:only="react">
<PopoverTrigger>{Astro.props.title} </PopoverTrigger>
<PopoverContent>
<slot name="children"/>
</PopoverContent>
</Popover> |
Beta Was this translation helpful? Give feedback.
-
Hello, I've been reading through some discussions that people have had in the past about integrating shacdn UI components (React and Tailwind based) into Astro projects.
I'm fairly new to the React and Astro worlds and, to be fair, I'm not very clever on fixing my own issues.
The thing about creating components and being able to reuse them as needed is one of my main concerns. I wanted to make my shacdn component reusable.
The following URL to the original component is here: https://ui.shadcn.com/docs/components/popover
As I've been reading elsewhere, I get the following error when calling a wrapped component that contains children inside:
Since Astro can't handle children from other UI framework as-is, I have to wrap it. But I want to make it dynamic it to call the component as many times as I want without any issues. My idea was to do something like this:
I would have to wrap this into a .astro extension file.
The code that actually does work is the following, with a .tsx extension file:
This way, I'd be able to call the component with a personalized popover trigger name and its content. But hell no, it does not work at all.
I honestly have no idea what I'm doing wrong and I really want it this way. I've been reading through other solutions, like inserting text into an array and using '.map' to go through all the content, but that's not my particular case in any way.
If anyone could help me, I would be very thankful.
Thanks in advance,
santvaz
Beta Was this translation helpful? Give feedback.
All reactions