I am confident this isn't possible as well it doesn't work lol
I am using webpack with babel-preset-es2015
& babel-preset-react
and trying to dynamically build a form using data passed between the routes.
Page loading < Form />
<Form data={
[
{
element: 'input',
type: 'text',
placeholder: 'Jamie is Sex'
},
{
element: 'input',
type: 'text',
placeholder: 'Jamie is Not Sex'
},
{
element: 'input',
type: 'password',
placeholder: 'Jamie is Not Sex'
}
]
}/>
< Form /> / form.js
var buildElements = this.props.data.map(function (item) {
var element = import item['type'] from './'+item['type'];
return element;
});
I realise I could do an if statement but I want it to rely on the filesystem. Maybe I need to check if the file exists with node.