Working version
// Load from defined component
const TextField = require('textfield');
render: function() {
<div>
<TextField label='sample' defaultValue='default' placeholder='type your value' />
</div>
}
Improved version, but not working
And then I have so many TextField, so I refactor my code to create the props in a more generic way. Then, I expect kind of things like this will work, but it won't:
render: function() {
<div>
// This not working but raised error: Objects are not valid as a React child (found: object with keys: {label, defaultValue, placeholder}
React.createElement(TextField, this._getPropsForField('sample'))
</div>
},
_getPropsForField: function(fieldName) {
// Initialize data for fieldName, but return a mock for now
return {
label: 'sample',
defaultValue: 'default',
placeholder: 'placeholder'
};
}
I also tried:
TextField(this._getPropsForField())
But it didn't work with the same error.
I appreciate any help or suggestion, thank you guys!