Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode user snippet doesn't works inside jsx

I have a some snippet:

"JSON stringify": {
        "prefix": "jst",
        "body": [
            "<pre>{JSON.stringify($1, null, 2)}</pre>"
        ]
    },

and it works inside js scope, but when I'm trying to do same trick inside jsx render - it dont want to be working.

How to tell my VSCode, that I want to do same things inside jsx?

enter image description here

like image 558
WebArtisan Avatar asked Jul 31 '18 08:07

WebArtisan


People also ask

How do I enable VSCode snippets?

There is also support for tab-completion: Enable it with "editor.tabCompletion": "on" , type a snippet prefix (trigger text), and press Tab to insert a snippet.


2 Answers

Maybe adding "scope" to your snippet:

"scope": "javascript,typescript,javascriptreact",

javascriptreact ---> jsx files

It should be like this...

"JSON stringify": {
  "scope": "javascript,typescript,javascriptreact",
  "prefix": "jst",
  "body": [
    "<pre>{JSON.stringify($1, null, 2)}</pre>"
  ]
},
like image 116
jdmaldonado Avatar answered Oct 04 '22 04:10

jdmaldonado


Putting that snippet into your global snippets file should work.

Gear Icon/User Snippets/ myGlobalSnippets.code-snippets

like image 33
Mark Avatar answered Oct 04 '22 04:10

Mark