Solid JS to mixins or HOCs

I've got a situation where I'd like to create a component that modifies a specific type of child component. In React I would do this using a 'render props' function or a HOC. Is there an equivalent in SolidJS?
2 Replies
Alex Lohr
Alex Lohr2y ago
You can use the children() helper to evaluate the contents of the children props. It's return value has a handy toArray() method. But be aware that in Solid, children are HTML Elements in browser mode and objects with a t-property containing the rendered template in SSR. Also, if you are using hydration, these elements will have certain data attributes that needs to be preserved, or else you'll have errors on hydration. In any case, HOCs manipulating the child nodes is considered an anti-pattern even in react. Maybe consider a context to set certain values in the children from the parent instead.
Ghirigoro
GhirigoroOP2y ago
Thanks! !close
Want results from more Discord servers?
Add your server