Skip to content

Instantly share code, notes, and snippets.

@mahendra0859
Last active March 9, 2020 13:48
Show Gist options
  • Save mahendra0859/2385520dd5f1061a8879369ab3d66a1d to your computer and use it in GitHub Desktop.
Save mahendra0859/2385520dd5f1061a8879369ab3d66a1d to your computer and use it in GitHub Desktop.
Custom Snippets in Visual Studio Code

Snippets in Visual Studio Code

code > Preferences > User Snippets > New Global Snippets File > newSnippet.code-snippet
file path : /Users/username/Library/ApplicationSupport/Code/User/snippets
{
	"React stateless functional component": {
		"scope": "javascriptreact",
		"prefix": "fcomp",
		"body": [
			"import React from 'react'",
			" ",
			"const ${1:ComponentName} = ()=><div>${i:componentName}</div>",
			" ",
			"export default ${1:componentName}"
		],
		"description": "Create a React stateless functionl component"
	},
	"React stateful functional component": {
		"scope": "javascriptreact",
		"prefix": "fscomp",
		"body": [
			"import React, { useState } from 'react'",
			" ",
			"const ${1:ComponentName} = () => {",
			" ",
			" const [state, setState] = useState();",
			" ",
			" return <div>${1:componentName} $0</div>",
			"}",
			"export default ${1:componentName}"
		],
		"description": "Create a React stateful functionl component"
	}
}

Youtube reference link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment