Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,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.