Question
In the context of this exercise, can we only create one component instance at a time?
Answer
When running the ReactDOM.render()
method, you can only pass in one value as the first argument, which is the component to be rendered. However, you can create more than one component instance at a time, by simply wrapping them inside of another element, such as a <div>
. For example, you could do the following to render two components,
ReactDOM.render(
<div>
<ComponentOne />
<ComponentTwo />
</div>,
document.getElementById('app')
);
Another option is to create another component for the purpose of wrapping multiple components to render.