VSCode does not auto-import from “react” in Next.js projects

* This is not a duplicate of this question; the accepted answer there is made for TypeScript and doesn’t seem to work for JavaScript.

I am working on a Next.js project in Visual Studio Code, and when trying to auto-import anything from "react", the only auto-import suggestions come from "react.production.min" and "react.development".

I can manually import from "react", but even when I already have an import { ... } from "react" statement in the file, it still doesn’t show up in the auto-import suggestions, and manually importing every hook I use can get quite tedious.

VSCode auto-import problem

Is there a way to fix this?