React.createElement( type, [props], [...children] )
as the react documentation said. But somehow it's not working for me with multiple props. I tried to pass an array of key-value objects, pass a container object with key-values, but nothing isn't worked. Let me show how I tried it:
//input.js
const Input = ({name, elementProps}) => {
const { element, props } = elementProps;
return React.createElement(element, props)
}
export default Input;
//props from
{
name: "msg",
element: "textarea",
props: [
{placeholder: "Message"},
{rows: "4"},
{cols: "50"},
]
}
//rendered by method
const { name, ...elementProps } = objectAbove;
return <Input name={name} elementProps={elementProps} />
What's the required syntax to pass multiple props?