Quick Fix command for missing React component imports does not work without React in the scope even with the new JSX factory enabled in Next.js that makes the React import unnecessary
See original GitHub issue- VSCode Version: 1.51.0
- OS Version: macOS 10.15.7
- Typescript Version: 4.0.5
Steps to Reproduce:
- Clone the following repository: https://github.com/ChristianIvicevic/react-jsx-factory-repro
yarn install
all dependencies- Open the
index.tsx
and add theSampleComponent
without automatic completion and import of the component - Try to use Quick Fix on the
SampleComponent
to automatically add its import - Only the fix to import React is available initially - apply this Quick Fix
- Open the Quick Fix for a second time - now you are able to add the import for the
SampleComponent
Here is a gif of the differences with automatic import and with Quick Fixes:
With the newest version of Next.js it is no longer necessary to import the default export of React, thus step 5 should not appear in the first place.
Does this issue occur when all extensions are disabled?: Yes
Issue Analytics
- State:
- Created 3 years ago
- Reactions:45
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Introducing the New JSX Transform – React Blog
Remove all unused React imports as a result of upgrading to the new JSX transform. Change all default React imports (i.e. import React...
Read more >'React' must be in scope when using JSX ... - Stack Overflow
The import line should be: import React, { Component } from 'react';. Note the uppercase R for React.
Read more >Migrating from Create React App - Next.js
Migrating from Create React App. This guide will help you understand how to transition from an existing non-ejected Create React App project to...
Read more >typescript-cheatsheet - GitHub Pages
A set of TypeScript related notes used for quick reference. The cheatsheet contains references to types, classes, decorators, and many other TypeScript ...
Read more >The starting point for learning TypeScript
TypeScript Documentation. Get Started. Quick introductions based on your background or preference. TS for the New Programmer · TypeScript for JS ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Next.js (which is what this issue was opened about) uses
"jsx": "preserve"
in its tsconfig so unfortunately that PR doesn’t solve this (tested with the 4.3.0-beta release of typescript & stable VS Code).@billyjanitsch
Unfortunately, this still persists 😦 (typescript@4.3.4)