移除react遇到的问题 2021-04-23

What comes out the error "TypeError: Cannot read property 'createContext' of undefined"?

I want to try to make authorize via Google and try to use TS.
Did a simulated authorization sagas and all worked OK. Then all components were in jsx.
Now everything is going without errors but in the console gives an error

Uncaught TypeError: Cannot read property 'createContext' of undefined
at eval (Context.js:4)
at Object../node_modules/react-redux/es/components/Context.js (the bundle.min.js:497)
at __webpack_require__ (the bundle.min.js:20)
at eval (Provider.js:7)
at Object../node_modules/react-redux/es/components/Provider.js (the bundle.min.js:509)
at __webpack_require__ (the bundle.min.js:20)
at eval (index.js:3)
at Object../node_modules/react-redux/es/index.js (the bundle.min.js:665)
at __webpack_require__ (the bundle.min.js:20)
at eval (index.tsx:5)

ry to add the loader
exclude: /node_modules/
And in tsconfig.json you can add:
"allowSyntheticDefaultImports": true,
and use a normal import in your code:
import React from 'react';

The problem, as I understood, that the property "allowSyntheticDefaultImports" set to the value false, the loader parses the library in node_modules, and default imports React to do with the current settings can not.
Thank you. helped. Only if you do a normal import, it will pop up a similar error, but instead will createContext Component. Therefore, the import left, and the rest was replaced as you said. - Sandra_Homeni commented on March 24th 20 at 14:50
@Sandra_Homeni, try to add in tsconfig.json is still here:
"moduleResolution": "node",
and try again. - haze commented on March 24th 20 at 14:53

你可能感兴趣的:(移除react遇到的问题 2021-04-23)