Skip to content

Instantly share code, notes, and snippets.

@jwrigh26
Created February 16, 2023 23:12
Show Gist options
  • Save jwrigh26/31bd947321ebc58549051891b893a79f to your computer and use it in GitHub Desktop.
Save jwrigh26/31bd947321ebc58549051891b893a79f to your computer and use it in GitHub Desktop.
My JS Snippets
{
// Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Log value to console": {
"prefix": "lg-var",
"body": ["console.log($1);", "$2"],
"description": "Log value and string output to console"
},
"Log string to console": {
"prefix": "lg-str",
"body": ["console.log('$1');", "$2"],
"description": "Log value and string output to console"
},
"Log out and Stringify a value": {
"prefix": "lg-jsn",
"body": ["console.log(`${JSON.stringify($1, null, 2)}`);", "$2"],
"description": "Log value and string output to console"
},
"Stringify a value": {
"prefix": "json-stringify",
"body": ["JSON.stringify($1, null, 2)}`);$2"],
"description": "Log value and string output to console"
},
// "Print to console": {
// "prefix": "lg-str",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log string to console"
// },
// "Log to console": {
// "prefix": "lg-var",
// "body": [
// "console.log($1);",
// "$2"
// ],
// "description": "Log output to console"
// },
// "Log value and string to console": {
// "prefix": "lg-str-var",
// "body": [
// "console.log('$1', $2);",
// "$3"
// ],
// "description": "Log value and string output to console"
// },
"React function component": {
"prefix": "jw-rfc",
"body": [
"import * as React from 'react';",
"import PropTypes from 'prop-types';",
"",
"export default function ${TM_FILENAME/(.*)\\..+$/${1:/capitalize}/}() {",
" return <div>Hello${TM_FILENAME/(.*)\\..+$/${1:/capitalize}/}</div>;",
"}",
"",
"${TM_FILENAME/(.*)\\..+$/${1:/capitalize}/}.propTypes = {};",
"$0",
],
"description": "React Functional Component with Classnames prop"
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment