-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React 17 default to react-jsx
in tsconfig
#5090
Comments
Did you try that? I have added a lib with |
We can do this without checking since nx 10.4.0 already migrated workspaces to React 17. We just need to make sure we enable this in our Will do this for the next release |
Yes, the following works for me:
|
We'll need to update TS version as well to support There's a separate PR incoming to update the generators and migrations. Targetting for Nx 12 release. |
Thanks @jaysoo looking forward to the next version. Can we also add a eslint rule to not import the default export from react (seeing as that will eventually go away and be a breaking change)? |
I found // .babelrc
{
"presets": [
[
"@babel/preset-react",
{
"useBuiltIns": true,
"runtime": "automatic",
"importSource": "@emotion/react"
}
]
],
"plugins": ["@emotion/babel-plugin"]
}
// tsconfig.json
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"jsx": "react-jsx",
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
}
]
} |
Does such a rule exist for React? |
@puku0x Emotion migration has been added https://github.com/nrwl/nx/pull/5131/files#diff-a477196d7726c04ca7eb1ec5b8dd71c4fe6d1f12e13515c9f040851456e2d744R1 New apps/libs will also generate with |
@jaysoo I am not sure if there's a eslint rule for it right now. In fact the react-plugin-react/recommended preset for eslint has this turned on which I had to explicitly turn off in my .eslintrc.json rules: {
'react/react-in-jsx-scope': 'off',
'react/jsx-uses-react': 'off'
} I did however find this Maybe the rule can be written as part of the @nrwl/react package? TSQualifiedName(node) {
if (node.left.name === 'React') {
context.report(
node,
'Do not use React qualifier, use import deconstruction instead',
);
}
}, Further reading: |
@cyrus-za Thanks for the pointers. We have turned the two eslint rules off in our I've opened an issue here to capture your eslint rule request. #5198 |
Thanks @jaysoo I'm upgrading to nx12 right now :) |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
With react 17 the import of React is not required to use jsx, but this is only possible if we got
in the tsconfig.json file.
Can the
@nrwl/react
generator check the version of react in package.json and if its >= 17.0.0 then set that in tsconfig?The text was updated successfully, but these errors were encountered: