Uncaught ReferenceError: React is not defined Uncaught ReferenceError: React is not defined reactjs reactjs

Uncaught ReferenceError: React is not defined


Change your app.js to this

var React = require('react');var ReactDOM = require('react-dom');var Home = require('./components/homePage');ReactDOM.render(    <Home/>,    document.getElementById('app'));

JSX is transformed into React.createElement() calls, thus React is required in scope. So yes, you are using React in app.js.Get used to import it whenever you use JSX or direct React.* calls.


You can have it without require it in your code.

Add to webpack.config.js:

plugins: [  new webpack.ProvidePlugin({    "React": "react",  }),],

See https://webpack.js.org/plugins/provide-plugin/#root