'React' must be in scope when using JSX react/react-in-jsx-scope?
Add below setting to .eslintrc.js
/ .eslintrc.json
to ignore these errors:
rules: {
// suppress errors for missing 'import React' in files
"react/react-in-jsx-scope": "off",
// allow jsx syntax in js files (for next.js project)
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }], //should add ".ts" if typescript project
}
Why?
If you're using NEXT.js
then you do not require to import React
at top of files, nextjs does that for you.
Ref: https://gourav.io/blog/nextjs-cheatsheet (Next.js cheatsheet)
The import line should be:
import React, { Component } from 'react';
Note the uppercase R for React.