Skip to content

Instantly share code, notes, and snippets.

View jmaicaaan's full-sized avatar

JM Santos jmaicaaan

  • Philippines
View GitHub Profile
"React Component": {
"prefix": "react#component",
"body": [
"export type ${1/(.*)/${1:/capitalize}Props/} = {};",
"export const ${1/(.*)/${1:/capitalize}/} = (props: ${1/(.*)/${1:/capitalize}Props/}) => {",
" return (",
" $2",
" );",
"};"
],
"React Component using filename": {
"prefix": "react#component-use-filename",
"body": [
"export const ${TM_FILENAME_BASE/(.*)/${1:/capitalize}/} = (props) => {",
" return (",
" $2",
" );",
"};"
],
"description": "Create a functional React component based on the filename"
"React Component": {
"prefix": "react#component",
"body": [
"export const ${1/(.*)/${1:/capitalize}/} = (props) => {",
" return (",
" $2",
" );",
"};"
],
"description": "Create a functional React component"
"React useRef": {
"prefix": "react#useRef",
"body": [
"const ${1:ref} = useRef<$2 | null>(${3:null});"
],
"description": "React useRef for TypeScript"
}
"React useRef": {
"prefix": "react#useRef",
"body": [
"const ${1:ref} = useRef(${2:null});"
],
"description": "React useRef"
}
"React useEffect": {
"prefix": "react#useEffect",
"body": [
"useEffect(() => {",
" $1",
"}, [$2]);"
],
"description": "React useEffect"
}
"React useState with typings": {
"prefix": "react#useState",
"body": "const [${1}, set${1/(^[a-zA-Z])(.*)/${1:/upcase}${2}/}] = useState<$3 | null>(null);",
"description": "React useState with typings"
}
"React useState": {
"prefix": "react#useState",
"body": "const [${1}, set${1/(^[a-zA-Z])(.*)/${1:/upcase}${2}/}] = useState(null);",
"description": "React useState"
}
"Named function with typings": {
"prefix": "ts#function",
"body": [
"export type $1Params = {};",
"function $1(params: $1Params) {",
" $2",
"}"
],
"description": "Create a named function with typings"
}
"Named function using filename": {
"prefix": "js#function-use-filename",
"body": [
"function ${1:${TM_FILENAME_BASE}}(${2:params}) {",
" $3",
"}"
],
"description": "Create a named function with filename as the default function name"
}