ParentProps usage and reactivity

When using Parent Props do i still need to use the children helper function or would this be okay
import {ParentProps} from "solid-js";

interface PrimaryButtonProps {
colorClass: string;
onClick: () => void;
}

export default function PrimaryButton(props: ParentProps<PrimaryButtonProps>) {
return (
<button
onClick={props.onClick}
class={"btn-action w-full flex items-center justify-center gap-2 py-3.5 px-4 rounded-xl text-white font-bold text-lg shadow-lg ${colorClass} hover:opacity-90 focus:ring-4 focus:ring-opacity-50 focus:outline-none"}
>
{props.children}
</button>
);
}
import {ParentProps} from "solid-js";

interface PrimaryButtonProps {
colorClass: string;
onClick: () => void;
}

export default function PrimaryButton(props: ParentProps<PrimaryButtonProps>) {
return (
<button
onClick={props.onClick}
class={"btn-action w-full flex items-center justify-center gap-2 py-3.5 px-4 rounded-xl text-white font-bold text-lg shadow-lg ${colorClass} hover:opacity-90 focus:ring-4 focus:ring-opacity-50 focus:outline-none"}
>
{props.children}
</button>
);
}
1 Reply
jer3m01
jer3m013d ago
children() is required when you want to reuse children multiple times your case only 1 usage so no need

Did you find this page helpful?