S
SolidJS2mo ago
siduck

How to modify props of children?

In react i was using CloneElement, how to achieve this in solidjs? {props.children[0]} i want to add onclick method to this
7 Replies
Madaxen86
Madaxen862mo ago
There’s a thread discussing this. Short: you don’t. There’s no cloneElement because children are html elements not jsx elements. You can use context, to pass props to children or use the children helper and then manipulate the html elements with native js methods. Can you provide a specific use case? https://discord.com/channels/722131463138705510/1258411547701542923
siduck
siduckOP2mo ago
I think idont need this anymore cuz Ive decided to use <DropdownItem> component for this 🤔
siduck
siduckOP2mo ago
No description
siduck
siduckOP2mo ago
i wanted to make dropdown component then in the component, attach the onclick prop to the 1st button there but this is too much work as i'd have to modify the prop in Effect
siduck
siduckOP2mo ago
so i want to have something like this
No description
Madaxen86
Madaxen862mo ago
If you design your own components just provide a drop-down trigger component to open and close the drop-down. A good example is https://kobalte.dev Exactly 👍 And there’s the dynamic component which you can use if you want to let the user decide which element tag or custom element they want to use.
Madaxen86
Madaxen862mo ago
Dynamic -
Documentation for SolidJS, the signals-powered UI framework

Did you find this page helpful?