Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebStorm auto completion does not work for React js

I've created a project using create-react-app. I have switched my JavaScript language version to React JSX in Preferences | Languages & Frameworks | JavaScript. But I still have unresolved variable warning and unresolved function warning.

like image 360
Mihail Boiarskii Avatar asked Oct 22 '17 07:10

Mihail Boiarskii


People also ask

Does WebStorm support react JS?

React Native allows you to develop native mobile apps for iOS and Android using JavaScript and React.

How do you AutoComplete in WebStorm?

Start typing a name. By default, WebStorm displays the code completion popup automatically as you type. If automatic completion is disabled, press Ctrl+Space or choose Code | Code Completion | Basic from the main menu. To get more suggestions, press Ctrl+Space for the second time (or press Ctrl+Alt+Space ).

Why AutoComplete is not working in Intellij?

I have tried the following according to this thread (Intellij IDEA CE 12 Android XML Code Completion not working): Go to File->Power Save Mode and disable it - it is off. Go to Preferences->Editor->Code Completion and check Autopopup code completion - this has been checked. Go to File->Invalidate Caches and restart.


1 Answers

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 webstorm js libraries setup
  • click Download...
  • search for any libraries you need (you can just start typing lib name in libs list), then click Download and Install download and install TS libraries
  • when using react, I suggest to add: react; react-dom; react-native (if you interested in mobile dev)
  • click Apply when you done added TS libraries

commonly you don't need to restart IDE, changes will apply immediately. Happy coding!

like image 69
Bender Avatar answered Oct 16 '22 07:10

Bender