solidJS equivalent of react's cloneElement
I'm trying to convert a react component that uses cloneElement to a solidJS component. I've briefly glanced at some of the messages on discord concerning cloneElement and I haven't seen anything definitive. lxsmnsyc mentioned using solid-headless.
Original react code:
This is as far as I got with my solidJS conversion:
This is what chatGPT recommended:
6 Replies
I never mentioned it. Any link?
you should also consider @thetarnav 's previous message https://discord.com/channels/722131463138705510/722131463889223772/1174823721077325874
https://discordapp.com/channels/722131463138705510/1016160314837979146/1016183102231560263
I've read a lot of the messages. Not sure which one
Oh
he warned me. Think this is beyond me
yeah you basically have to rethink how to approach this
lmao
I knew this will be an issue as soon I as saw cloneElement
what chat gpt recommended is kinda in the right way, but it doesn't show why
from what I understand, in react, this source jsx:
should give you this html on desktop:
and on mobile:
more or less at least
in react you can modify the jsx data structure after it was called and before it was rendered
but in solid jsx resolves to html element directly so it's too late
you need to be able to get the right result the moment you call all the jsx elements
this is why you usually use callbacks to make the evaluation lazy, so you have additional time to decide where and how many times to call it. Like
<For>
and <Show>
components do.
maybe it would be the easiest to do it by providing the data up-front and focus only on th an td elements