I've updated to React 17+ and am now getting a React is not defined issue when removing
import React from 'react' statements from typescript TSX and JSX files.
How can I fix this?
I've updated to React 17+ and am now getting a React is not defined issue when removing
import React from 'react' statements from typescript TSX and JSX files.
How can I fix this?
I've identified the problem is the version of a few babel plugins that are outdated that Parcel (version 2.0.0-beta.3.1 at time of writing) is using.
Here's my solution:
Add these two packages to you package.json file:
yarn add --dev @babel/core @babel/plugin-transform-react-jsx
or
npm i -D @babel/core @babel/plugin-transform-react-jsx
update your babel config or create a new .babelrc file:
{
"plugins": [
[
"@babel/plugin-transform-react-jsx",
{
"runtime": "automatic"
}
]
]
}