-=Camille=-
-=Camille=-
SSolidJS
Created by -=Camille=- on 5/10/2024 in #support
Component that can render a different tag depending on prop?
Thank you for the advice!
14 replies
SSolidJS
Created by -=Camille=- on 5/10/2024 in #support
Component that can render a different tag depending on prop?
🙏
14 replies
SSolidJS
Created by -=Camille=- on 5/10/2024 in #support
Component that can render a different tag depending on prop?
Okay, thanks for the feedback! You are right, I also thought that I would have to put warnings for future devs that component would not react to changes to the as prop. It's probably too much risk for a low impact on the website's performance. Thanks for the help 🙂
14 replies
SSolidJS
Created by -=Camille=- on 5/10/2024 in #support
Component that can render a different tag depending on prop?
Okay thanks. I'm just wondering if using a Dynamic component to just return a different header depending on the prop is a bad idea, since I actually don't need dynamism. Should I just use the prop outside a reactive context to improve the performance? I guess I would lose reactivity, but gain performance by removing the reactivity checks. I know I would not notice any significant difference, but I would like my code and websites to have the least performance impact as possible. I'm striving for eco-friendliness. 😄
14 replies
SSolidJS
Created by -=Camille=- on 5/10/2024 in #support
Component that can render a different tag depending on prop?
This title is not really dynamic, I just want to render a different heading level once and then leave it like this 😄
14 replies
SSolidJS
Created by -=Camille=- on 5/10/2024 in #support
Component that can render a different tag depending on prop?
Is this because it's cleaner and Switch and Dynamic have the same impact? I'm just wondering if the Dynamic component has a bigger impact. The reason is that this Title will be used everywhere in my website, and I would rather not impact the performance too much. 😓
14 replies
SSolidJS
Created by -=Camille=- on 5/10/2024 in #support
Component that can render a different tag depending on prop?
I could also use a Dynamic component like this, but I don't know which is the best solution. 🤔
return (
<Dynamic component={props.as ?? 'h1'} classList={getClasslist()}>
{props.children}
</Dynamic>
);
return (
<Dynamic component={props.as ?? 'h1'} classList={getClasslist()}>
{props.children}
</Dynamic>
);
14 replies