简体   繁体   中英

React suggestions and autocomplete does not work for files with js extension in VSCode

I need to enable React related suggestions and autocomplete but in files with .js extension in Visual Studio Code. The only way to make it working for me is to change extension from .js to .jsx . I tried everything described in this post but nothing worked for me.

Here is what I mean by React related suggestions and autocomplete. 在此处输入图像描述

"*.jsx" extension assosiacted with javascriptreact language mode .

Change the file type from javascript to javascriptreact , you can do it from the bottom panel.

Or run Change language Mode from command palette ( ctrl+p ).

Also, you can add files.associtiations on your settings.json :

  "files.associations": {
    "*.react.js": "javascriptreact",
    "*.jsx": "javascriptreact",
    "*.js": "javascriptreact",
  }

语言模式

I am also having same problem but when I keep index.js file open in background everything just works. You can also try

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