I am trying to render HTML from JSON into my React component. I am aware of the dangerouslySetInnerHTML and am not looking to use that as I would like to leverage other React components inside of the rendered HTML. Currently I can render any element as long as I close the tag. But this is not the case as in if I would like to put multiple elements or img tags in a div i would need it to remain open until all of the img tags have completed. I would appreciate any help on this. Thanks
render(){ var data = [ { type: 'div', open: true, id: 1, className: 'col-md-12 test', value: '' }, { type: 'div', open: false, id: 1 } ] var elements = data.map(function(element){ if(element.open){ return <element.type className={element.className}> } else { return </element.type> } }) return ( <div> {elements} </div> ) } webpack error
3 | return <element.type className={element.className}> 34 | } else { > 35 | return </element.type> | ^ 36 | } 37 | }) 38 | return ( @ ./src/index.js 9:11-38