react is not defined
See original GitHub issueUpdated to React 16 and Enzyme 3 - using mocha with webpack
import React from 'react';
import Enzyme, { render } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
Enzyme.configure({ adapter: new Adapter() });
describe('...', () => {
// ...
});
Webpack externals:
externals: {
jsdom: 'window',
'react/addons': true,
'react/lib/ExecutionEnvironment': true,
'react/lib/ReactContext': 'window',
'react-dom/test-utils': true,
'react-test-renderer/shallow': true,
},
I get the error ReferenceError: react is not defined
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (7 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 >'X' is not defined react/jsx-no-undef Error in React | bobbyhadz
The React.js error "X is not defined react/jsx-no-undef" occurs when we forget to import a function, class or a variable in our code...
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 >[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 >React is not defined after migrating to React 17 - Meteor forums
Hello, I migrated to React v17. I know that now it is not necessary to import React from 'react'; so I deleted it...
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
Do you have
react-test-renderer
in your dev deps? Trynpm ls
- if it returns nonzero then nothing can be expected to work.@trigunam this has nothing to do with enzyme. React’s latest blog post says you need both React 17 and also custom babel configuration to be able to avoid importing React.