Children

We can compose a DOM node

var p1 = React.DOM.p(null, 'first p');
var p2 = React.DOM.p(null, 'second p');
var div = React.DOM.div(null, p1, p2);
var el = document.getElementById('example');
React.render(div, el);

I've written this in longhand and created a fair few unnecessary variables here. Let's simplify this a little.

var node = React.DOM.div(null,
React.DOM.p(null, 'first p'),
React.DOM.p(null, 'second p')
);
var el = document.getElementById('example');
React.render(node, el);

Do you like Email? Do You Like JavaScript?

Sign up for occasional emails covering modern Web Development topics such as Angular 2 and React. You can unsubscribe at any time.

We totally respect your email privacy

comments powered by Disqus