Pregunta

I create a menu using React JS:

var Dropdown = React.createClass({
  render: function() {
    return (
      <Title />
      <OptionsDropdown />
    );
  }
});

where Title and OptionsDropdown are other React classes. The problem is this code has error until I wrap them around a div like :

var Dropdown = React.createClass({
  render: function() {
    return (
      <div class="something">
        <Title />
        <OptionsDropdown />
      </div>
    );
  }
});

Is there anyway better to handle this situation when I want no div is wrapped outside Title and OptionsDropdown.

No hay solución correcta

Otros consejos

Finally. I found out there is maximum one root node in render function in React JS. Better to wrap it with a div.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top