Here is a function that has two parameters:
- The name of the tag that I want to create
- An object that has the properties
Using React, I create a component and render that element to DOM. The problem is that I want to add properties to the element, but it does not allow the loop to set properties within element.
var Element = function(element, properties) {
var newElement = React.createClass({
render: function() {
return (
React.createElement(element, {}, 'react reuseable')
);
}
});
ReactDOM.render(React.createElement(newElement, null), document.getElementById('content'));
}
Here is the function call to create a React element:
Element('g', {
id: 'DrawingController.drawingPathCounter ' + '_shape',
d: 'path',
fill: 'none',
stroke: 'Controllers.TemplateController.wireFrameColour_Selected',
'stroke-width': 1,
'class': 'drawingpath',
pathhover: '',
'vector-effect': 'non-scaling-stroke'
})