question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught ReferenceError: react is not defined

See original GitHub issue

I’m not sure where I’m going wrong, but it seems I can’t get the component to load in a browser. I get this error Uncaught ReferenceError: react is not defined in the console.

To reproduce try creating a boilerplate app with react-create-app. Then modify the src/App.js file minimally to include the QueryBuilder component. Here is mine

import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import QueryBuilder from 'react-querybuilder';

class App extends Component {
  render() {

    const fields = [ 
        {name: 'firstName', label: 'First Name'},
        {name: 'lastName', label: 'Last Name'},
        {name: 'age', label: 'Age'},
        {name: 'address', label: 'Address'},
        {name: 'phone', label: 'Phone'},
        {name: 'email', label: 'Email'},
        {name: 'twitter', label: 'Twitter'},
        {name: 'isDev', label: 'Is a Developer?', value: false},
    ];  

    function logQuery(query) {
        console.log(query);
    }   

    return (
      <div className="App">
        <div className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <h2>Welcome to React</h2>
        </div>
        <div>
            <QueryBuilder fields={fields} onQueryChange={logQuery}/>
        </div>
        <p className="App-intro">
          To get started, edit <code>src/App.js</code> and save to reload.
        </p>
      </div>
    );  
  }
}

export default App;

On Stackoverflow someone thinks you need to include react via script tag because react-querybuilder expects a global react variable; is that assessment correct?

I’ve tried adding a script tag atop my index.html file before loading the app bundle like this

   <body>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react.min.js"></script>
      <div id="root"></div>
   </body>

yet the error persists.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
quickshiftincommented, Jan 24, 2017

Verified on my end as well; thanks guys!

1reaction
pavanpodilacommented, Jan 23, 2017

This should be fixed now. Most of the work was done by @mrvicadai. I fixed a few imports and did some package updates. Version should now be 1.3.4

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught ReferenceError: React is not defined - Stack Overflow
Possible reasons are 1. you didn't load React.JS into your page, 2. you loaded it ...
Read more >
Getting "Uncaught ReferenceError: react is not defined".
Hi Louie Ambriz, It's hard to tell without seeing your code but it sounds like React is not being loaded into your project....
Read more >
How to Fix the 'Uncaught ReferenceError: React is not defined ...
To fix the 'Uncaught ReferenceError: React is not defined' error when developing React apps, we can add the 'react' property to the externals...
Read more >
[v4]ReferenceError: React is not defined · Issue #9882 - GitHub
I have submitted PR #9885 to fix this. This is because the jsx-runtime configuration gets removed webpack config during the ejection process ......
Read more >
Uncaught ReferenceError: React is not defined
yes, I am running in incognito, my code works fine with production cdn, when i change it to development version it gives this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found