How to make PyCharm JavaScript auto imports work correctly?
Up until recently PyCharm would automatically add node_modules import statements like:
import { useRef } from 'react';
now suddenly the only option it gives is this import
import { useRef } from 'react/cjs/react.production.min';
I've tried looking through the relevant preferences but have no idea what could be wrong. What settings have changed in recent updates that broke this?
请先登录再写评论。
What IDE version do you use? Do you have @types/react installed in your project?
PyCharm 2019.2.6 (Professional Edition)
Build #PY-192.7142.79, built on February 7, 2020
I am not using `TypeScript` so I do not have `@types/react` installed. This used to work correctly regardless.
Typings are used in JavaScript projects as well.
Is the issue reproducible for you in a new react project?
Adding `
react/*` to Do not import exactly from in Preferences | Editor | Code Style | JavaScript fixed the problem. Wonder if that used to be the default but now it's not anymore.@types/react was exactly what I needed to get rid of the wrong suggestion
import { useState } from 'react/cjs/react.production.min';Thanks!