Bug: React UMD cannot run in strict mode
See original GitHub issueReact version: 16.2.0
Steps To Reproduce
Run the code in your console:
import(‘https://cdn.jsdelivr.net/npm/react@16.12.0/umd/react.development.js’)
The current behavior
Uncaught (in promise) TypeError: Cannot set property 'React' of undefined
The expected behavior
React get loaded in the browser as globalThis.React
.
Suggestion
Head of https://cdn.jsdelivr.net/npm/react@16.12.0/umd/react.development.js
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.React = factory());
}(this, (function () { 'use strict';
The this
in the last line will always be undefined
in strict mode. Consider use this || globalThis
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Does strict mode work differently with React 18?
When components are wrapped in StrictMode , React runs certain functions twice in order to help developers catch mistakes in their code.
Read more >Strict Mode - React
Strict mode checks are run in development mode only; they do not impact the production build. You can enable strict mode for any...
Read more >rollup.js
When in watch mode, run a shell command <cmd> for a watch event code. ... Imported values cannot be reassigned, though imported objects...
Read more >Modules, introduction - The Modern JavaScript Tutorial
Always “use strict”. Modules always work in strict mode. E.g. assigning to an undeclared variable will give an error.
Read more >TypeScript errors and how to fix them
error TS1117 : An object literal cannot have multiple properties with the same name in strict mode. Broken Code ❌. 1 2 3...
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
Yeah we’d be happy to bump Rollup if there’s a fix.
It’s working in React 16.13.0