JSFiddle - React, Tailwind, and code Playground
by Mathias Bynens
JavaScript
(function() {
var arrDOM = [{
component: 'foo',
title: 'Hallo',
children: [{
component: 'bar'
},
{}]
},
{
component: 'bar',
title: 'Dit is comp #2',
children: [{
component: 'foo'
},
{}]
}],
arrComponents = {
foo: {
html: '<h1>dit is component foo</h1>'
},
bar: {
html: '<p>Dit is component bar</p>'
}
};
function parse(arrDOM) {
$.each(arrDOM, function(index, value) {
console.log(arrComponents[value.component]);
});
}
parse(arrDOM);
}());