Tag: uncaught referenceerror

Manatee Mistakes: Uncaught ReferenceError: ReactDOM is not defined

I am going to start blogging about errors and mistakes I have made while programming and what I did to fix them or circumvent them!

Here is my first entry:

Uncaught ReferenceError: ReactDOM is not defined

I made this error the first time I used a CDN for React (instead of downloading the npm module or using Webpack).

I google’d and used the first link: https://cdnjs.com/libraries/react

For development, I want to use the full version (not minified), so I selected  https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react.js.

I loaded only this script tag.

https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react.js

I got the error:

Uncaught ReferenceError: ReactDOM is not defined

What? I thought that this was all I needed!

I tried to import on my index.jsx (which had the ReactDOM.render()), but that didn’t alleviate the problem.  I read Stack Overflow. Apparently, I needed to also include the script react-dom file as well. So I did:

https://cdnjs.cloudflare.com/ajax/libs/react/15.6.1/react-dom.js

Doing just that gave me a really strange error (something like “do not use externally or you will be fired”), that I wish I took a screenshot of!

Thoroughly confused, I got the help of a mentor, and he got new CDNs for both React and React-DOM. Plus we used the crossorigin attribute, and that cleared all errors up. The ReactDOM.render() worked perfectly!

First Time with CDN
First Time with CDN
Advertisements