React will not let you render two adjacent components unless you wrap them inside a div. This has a downside: your app may contain a lot of wrapping divs.
ReactDOM.render(
<div>
<App1 />
<App2 />
</div>,
document.getElementById('root')
);
To avoid this issue, you can make use of the short syntax of the Fragments API which is included in React.
ReactDOM.render(
<>
<App1 />
<App2 />
</>,
document.getElementById('root')
);
That's it! no more dirty markup nor error messages :)
No comments:
Post a Comment