SolidJSS
SolidJS•4y ago•
15 replies
DaOfficialWizardđź§™

For Component

Hello ya'll, i have a <For> component with the following error:
This JSX tag's 'children' prop expects a single child of type '(item: Iinputs, index: Accessor<number>) => Element', but multiple children were provided.

With the following code:
interface FormProps {
    ...
    inputs: Iinputs[]
    ...
}

const FormComponent: Component<FormProps> = (props) => {
    return (
       <div class="flex-it">
           <For each={props.inputs}> {(input) => input.input()}</For>
        </div>
    )
}


My interfaces look like this:
export interface Iinternal {
    errorMsg?: string
    error?: boolean
}

export interface Iinputs {
    input: (props?: Iinternal) => JSXElement
}

I plan on passing in an array that looks like this:
export const inputs: Iinputs[] = [
    {
        input: (props?: Iinternal) => (
            <Inputs label="Email" type="password" name="password" id="password" {...props} />
        ),
    },
]

Any help would be appreciated - new to SolidJS.
Was this page helpful?