Uncaught ReferenceError: react is not defined
See original GitHub issueI’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:
- Created 7 years ago
- Reactions:1
- Comments:7 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Verified on my end as well; thanks guys!
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