Tuesday, September 6, 2016

Uncaught TypeError: React.render is not a function

When you run the following code:

const React = require('react');

ReactDOM.render(
  <App />,
  document.getElementById('react')
);

you might encounter the following error:

Uncaught TypeError: React.render is not a function

Add `react-dom` as follows:

sudo npm install react-dom --save

Import and use it as follows:

const React = require('react');
const ReactDOM = require('react-dom');

ReactDOM.render(
  <App />,
  document.getElementById('react')
);

Reference:
http://stackoverflow.com/questions/26627665/error-with-basic-react-example-uncaught-typeerror-undefined-is-not-a-function

No comments:

Post a Comment