close

[Solved] Uncaught ReferenceError: React is not defined

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Uncaught ReferenceError: React is not defined in javascript. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Uncaught ReferenceError: React is not defined Error Occurs?

Today I get the following error Uncaught ReferenceError: React is not defined in javascript.

How To Solve Uncaught ReferenceError: React is not defined Error ?

  1. How To Solve Uncaught ReferenceError: React is not defined Error ?

    To Solve Uncaught ReferenceError: React is not defined Error I got this error because in my code I misspelled a component definition with lowercase react.createClass instead of uppercase React.createClass.

  2. Uncaught ReferenceError: React is not defined

    To Solve Uncaught ReferenceError: React is not defined Error I got this error because in my code I misspelled a component definition with lowercase react.createClass instead of uppercase React.createClass.

Solution 1

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).

Solution 2

I got this error because in my code I misspelled a component definition with lowercase react.createClass instead of uppercase React.createClass.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also Read

Leave a Comment