移除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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容