WebStorm auto completion does not work for React js
The simplest way to achieve correct code completion while developing any (not only react) app is to add support for required type scrip libraries via IDE itself. Assuming you using JetBrains IDE for web dev (may be not WebStorm but IntelliJ IDEA):
- go to Settings (Ctrl + Alt + S) -> Languages & Frameworks
- expand JavaScript
- pick Libraries, you'll see something like this
- click Download...
- search for any libraries you need (you can just start typing lib name in libs list), then click Download and Install
- when using react, I suggest to add: react; react-dom; react-native (if you interested in mobile dev)
- click Apply when you done
commonly you don't need to restart IDE, changes will apply immediately.Happy coding!
To enhance code completion we recommend that you add a TypeScript definition file for React with
npm install --save @types/react
ref: blog.jetbrains
On WebStorm, open Preferences
, Expand the Languages & Frameworks
, then expand JavaScript
, click on Libraries
. Click the Add
button and add react to list of libraries.
Restart WebStorm.
Or
You do this:
You can add a TypeScript definition for React with npm install --save @types/react