according to new versions of React, we shouldn't always import React from 'react'
But I still have an error Uncaught ReferenceError: React is not defined
.babelrc (Switching an order of presets doesnt help, removing some of presets too)
{
"presets": [
[
"@babel/preset-react",
{
"runtime": "automatic"
}
],
"@babel/env",
"@babel/preset-typescript"
]
}
pakage.json
"react": "^18.0.0",
"react-dom": "^18.0.0",
"typescript": "^4.6.3",
"@babel/core": "^7.17.8",
"@babel/node": "^7.16.8",
"@babel/preset-env": "^7.16.11",
"@babel/preset-react": "^7.16.7",
"@babel/preset-typescript": "^7.16.7",
"@types/react": "^17.0.43",
"@types/react-dom": "^17.0.14",
"babel-loader": "^8.2.4",
For anyone stupid like me, Babel silently ignored my babel config file because a config already existed in the package.json file. Make sure you only have one config source, I guess.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With