JavaScript React Basics First Steps in React Add React to a Project

Michael Vanderloon
Michael Vanderloon
610 Points

ReactDom is not defined. My elements aren't rendering because when i load the page it says react dom is not defined.

I am using live-server to use serve the file using vs code as my editor.

Bader Alsabah
Bader Alsabah
4,734 Points

Hi Michael,

I'm not sure exactly on your question - but if ReactDom is undefined - then this means your browser doesn't have access to React Library and therefore any React calls will be undefined.

I suggest making sure that when you load your index.html it includes the following CDN script calls

    <script crossorigin src=""></script>
    <script crossorigin src=""></script>
    <script src=""></script>
    <script type="text/babel" src="./app.js"></script>

Just make sure to replace app.js with the name of your JS/React code file if you have chosen a different name. These will make the React libraries available to you when running your React components.

Hope this helps!

1 Answer

If you are using a life server you can also install ReactDom as a dependency in your react app folder.