I'm learning React from a "First Principles" approach. I am concerned that a undefined variable can be rendered in root.render; error prone. Would anyone know why is this allowed? root.render().
root.render() should render the base of your application. The base component that gets rendered (usually App.jsx) should never be null. And if you're getting your root like this (or a similar way -- there are probably different ways to go about this):
Top comments (1)
root.render()should render the base of your application. The base component that gets rendered (usually App.jsx) should never be null. And if you're getting your root like this (or a similar way -- there are probably different ways to go about this):Then as long as your
index.htmlhas a<div id="root"></div>in it,document.getElementById("root")won't ever be null either.