I am trying to build a dynamic as possible app. So I thought why not build elements from just passing a json object to it.
I have this:
[
{
key: 1,
element: 'input',
type: 'text',
placeholder: 'Jamie is'
},
{
key: 2,
element: 'input',
type: 'text',
placeholder: 'Jamie is Not'
},
{
key: 3,
element: 'input',
type: 'password',
placeholder: 'Jamie is'
}
]
Each element from the array will get passed to my elements, so instead of having to define each attribute I'd like to just make sure I pass the correct attributes and have it build on the flu.
All hell breaks loose when I do this:
const input = React.createClass ({
render() {
let data = this.props.data;
return (
<input placeholder={data.placeholder} /> //current
<input {data} /> //desired
);
}
});