This easy to fix error is caused by calling ReactDOM without importing the react-dom npm package. It’s also possible you have a typo in your import.
$ npm install react-dom or $ yarn add react-dom
Then import it at the top of your file like this:
ReactDOM exports a default component, so you can import it with any name. It’s standard to call it ReactDOM, but you can use another name if you want, like this:
“SomeFunction” is undefined
Generally, any time you get an error that a function you are trying to run is undefined, it’s caused by an import problem. The most common causes are:
There is a typo in your import
This happens most often when you are importing the default export from a module and have a typo in the imported name. There is no error with the import, because you can import a default export with any name you want. The error only happens when you try to access the imported module with a name that doesn’t match
There is a typo in the name of a named export
If you are importing a named export from a module that you created, check the exports. It’s possible you have a typo in the name of the export. When importing named exports the name has to match otherwise the imported value will be undefined.
You are trying to import a named export from a module that only exports a default export
Confirm whether the module you are importing exports a default export, named export(s) or both.