Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript React Basics (2018) 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,738 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="https://unpkg.com/react@16/umd/react.development.js"></script>
    <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
    <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></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.