I am trying to make ReactJS work with rails using this tutorial. I am getting this error:
Uncaught ReferenceError: React is not defined
The displayed error
after that import react
Finally import react-dom
if error is react is not define,please add ==>import React from 'react';
if error is reactDOM is not define,please add ==>import ReactDOM from 'react-dom';
I got this error because I was using
import ReactDOM from 'react-dom'
without importing react, once I changed it to below:
import React from 'react';
import ReactDOM from 'react-dom';
The error was solved :)
I was facing the same issue.
I resolved it by importing React
and ReactDOM
like as follows:
import React from 'react';
import ReactDOM from 'react-dom';
Try to add:
import React from 'react'
import { render } from 'react-dom'
window.React = React
before the render()
function.
This sometimes prevents error to pop-up returning:
React is not defined
Adding React
to the window will solve these problems.
I got this error because in my code I misspelled a component definition with lowercase react.createClass
instead of uppercase React.createClass
.
import React, { Component, PropTypes } from 'react';
This may also work!