React, Uncaught ReferenceError: ReactDOM is not defined
You need to import ReactDOM
in Main.js
instead of App.jsx
, as Main
is where you are using ReactDOM
to render.
Also need to import React
in all files that use JSX.
Finally, also put react-router
imports into Main
, too.
The way imports work is, you import things you need, in places they're needed. It's not enough to import them once in one file and use in others.
Change Main.js
to look like
import ReactDOM from 'react-dom'
import React from 'react'
import { Router, Route, browserHistory, IndexRoute } from 'react-router'
ReactDOM.render((
<Router history = {browserHistory}>
<Route path = "/" component = {App}>
<IndexRoute component = {Home} />
<Route path = "home" component = {Home} />
<Route path = "about" component = {About} />
<Route path = "contact" component = {Contact} />
</Route>
</Router>
), document.getElementById('app'))
Uncaught ReferenceError: ReactDOM is not defined
ReactDOM
available since version 0.14.0, so you need to use React.render
(because you have a React version 0.13.3) instead,
setInterval(function() {
React.render(
<HelloWorld date={new Date()} />,
document.getElementById('example')
);
}, 500);
or upgrade your React
version and include ReactDOM
Changes in React 0.14
ReactDom is undefined
You have ReactDOM
but you don't have ReactDom
(case sensitive)
ReactDOM.render(<Main />, document.getElementById('root'));
ReactDom is not defined?
The global is ReactDOM
(note DOM
is all uppercase).
Uncaught ReferenceError: React is not defined
I was able to reproduce this error when I was using webpack to build my javascript with the following chunk in my webpack.config.json
:
externals: {
'react': 'React'
},
This above configuration tells webpack to not resolve require('react')
by loading an npm module, but instead to expect a global variable (i.e. on the window
object) called React
. The solution is to either remove this piece of configuration (so React will be bundled with your javascript) or load the React framework externally before this file is executed (so that window.React
exists).
Related Topics
Is There a Jquery Autogrow Plugin for Text Fields
How to Detect When a Youtube Video Finishes Playing
How to Include HTML in a Js Rails Response
How to Enable Touch on Multiple Buttons Simultaneously in React Native
Open File Dialog Box in JavaScript
Setting a Variable to Get Return from Call Back Function Using Promise
Angularjs - Ng-Cloak/Ng-Show Elements Blink
Concept - Distilling How a Promise Works
Twitter Bootstrap Rails Button Dropdown No Responding to Ajax
Which Ecmascript 6 Features Imply Strict Mode
Can Jquery .Keypress() Detect More Than One Key at the Same Time
Creating Range in JavaScript - Strange Syntax
Jquery or JavaScript to Find Memory Usage of Page