Register custom component props without default values

Currently, I need to give default values to component properties if I want them to be registered:
customElement(
'typebot-standard',
{
apiHost: '',
isPreview: false,
resultId: '',
startGroupId: '',
prefilledVariables: {},
typebotId: '',
},
Bot
)
customElement(
'typebot-standard',
{
apiHost: '',
isPreview: false,
resultId: '',
startGroupId: '',
prefilledVariables: {},
typebotId: '',
},
Bot
)
But that's really not convenient. Is there a way to register props without default values?
1 Reply
jesseb34r
jesseb34r2y ago
this is pretty cleanly handled by types:
import { Component } from 'solid-js';

type MyComponentProps = {
apiHost: string;
isPreview: boolean;
resultId: string;
startGroupId: string;
prefilledVariables: Record<string, unknown>;
typebotId: string;
}

const MyComponent: Component<MyComponentProps> = (props) => {/* component logic */}
import { Component } from 'solid-js';

type MyComponentProps = {
apiHost: string;
isPreview: boolean;
resultId: string;
startGroupId: string;
prefilledVariables: Record<string, unknown>;
typebotId: string;
}

const MyComponent: Component<MyComponentProps> = (props) => {/* component logic */}
and if you want your component to accept children you can use ParentComponent instead of Component
Want results from more Discord servers?
Add your server