Finally. I found out there is maximum one root node in render function in React JS. Better to wrap it with a div.
Is there any required div wrapper inside a React component
-
18-10-2022 - |
Frage
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.
Keine korrekte Lösung
Andere Tipps
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow