Skip to content

Instantly share code, notes, and snippets.

@malcolm-kee
Last active November 12, 2019 02:42
Show Gist options
  • Save malcolm-kee/aea4139c7c48d13ea8e4028444aaf240 to your computer and use it in GitHub Desktop.
Save malcolm-kee/aea4139c7c48d13ea8e4028444aaf240 to your computer and use it in GitHub Desktop.
Javascript snippets
{
"Import react": {
"prefix": "imr",
"body": ["import React from 'react';"],
"description": "import react"
},
"React useState": {
"prefix": "rus",
"body": "const [$2, set${2/(^.)/${1:/upcase}/}] = React.useState(${1});"
},
"React useEffect": {
"prefix": "rue",
"body": [
"React.useEffect(() => {",
"$1",
"}, []);"
]
},
"React useRef": {
"prefix": "rur",
"body": "const $1 = React.useRef<$2 | null>(${3:null});"
},
"Generate test": {
"prefix": "gen:test",
"body": ["test('$1', () => {", "$2", "});"],
"description": "Generate test case"
},
"Generate test suite": {
"prefix": "gen:desc",
"body": ["describe('$1', () => {", "$2", "});"],
"description": "Generate test suite"
},
"I am great": {
"prefix": "iamgreat",
"body": ["console.log('=========================');", "console.log('# I Am Awesome!!! #');", "console.log('=========================');"],
"description": "Generate test suite"
},
"import testing library": {
"prefix": "imt",
"body": ["import { render, fireEvent } from '@testing-library/react';", "import '@testing-library/react/cleanup-after-each';"],
"description": "Import testing library"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment