简体   繁体   中英

React/JS not showing possibilities (intellisense) VSCODE

I am currently learning React in Visual Studio Code. However, it does not seem to be doing the intellisense correctly. I might be missing something, or be doing something wrong. 在此处输入图片说明

I am expecting it to show " this.setState ". If I write the code manually it works, but it is very inconvenient to fully write out these names. Or to check the possibilities.

I've tried changing the option on the bottom from HTML to JSBabel. It does change the way it does the intellisense, however not quite correct yet. If I choose for JSbabel it does the autocomplete for me. So when I it automatically closes(which is nice), but when the correct option does not show up it will autocomplete the wrong things. And HTML does not autocomplete for me, neither does it sometimes show the right options.

I've been struggling with this for a while and I haven't found a way to do this yet.

Try moving your code out into a JavaScript file. VS Code's IntelliSense for JavaScript within html script blocks is quite limited, and it does not understand references to scripts. https://github.com/microsoft/vscode/issues/26338 tracks this but it unlikely to be fully addressed given the complexity of the problem

But in a normal JS file, you should get full react IntelliSense once you add a react import (You can also follow the steps in this answer to manually setup react intellisense)

use a constructor, and assign default value. Also for valide value, you can use jsdoc. 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM