How can we apply the render() method to root if we don’t even have root defined?
Okay, let’s assume this is a continuation of the previous exercise and we have root designated. But why do we use the second argument document.getElementById('app') in .render()? The root variable already contains the root to this element with the id ‘app’.
Seems to be a mistake. You can give feedback to the course authors and then perhaps they will fix it. You can select “Get Unstuck > Bugs > There’s an issue with the content” and report the issue in the exercise.
The explanation isn’t showing the whole code, so we can assume that the container and root have already been set up (along with the appropriate imports),
// Not shown in exercise, but we can assume it has already been done.
const container = document.getElementById('app');
const root = createRoot(container);
Then, we can render the JSX in the code snippet of the exercise as,
root.render(hello);
I think the course authors mixed up approaches during updates to the course.
The deprecated way of rendering (see documentation) would have been: