Skip to content

Instantly share code, notes, and snippets.

@ekoneko
Last active April 7, 2023 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekoneko/4e999dd91900b19d578dd2d025c9753b to your computer and use it in GitHub Desktop.
Save ekoneko/4e999dd91900b19d578dd2d025c9753b to your computer and use it in GitHub Desktop.
vscode snip
{
"React_Class": {
"prefix": "comp",
"body": [
"export interface ${TM_FILENAME_BASE}Props {}",
"export interface ${TM_FILENAME_BASE}State {}",
"export class ${TM_FILENAME_BASE} extends React.PureComponent<${TM_FILENAME_BASE}Props, ${TM_FILENAME_BASE}State> {",
" render () {",
" return (",
" <div />",
" )",
" }",
"}"
],
"description": "create React Class"
},
"HOC": {
"prefix": "hoc",
"body": [
"export interface ${TM_FILENAME_BASE}InjectProps {}",
"export interface ${TM_FILENAME_BASE}DependProps {}",
"export function with${TM_FILENAME_BASE}<OwnerProps>(WrappedComponent: React.ComponentType<OwnerProps & ${TM_FILENAME_BASE}InjectProps>) {",
" return class ${TM_FILENAME_BASE}Hoc extends React.PureComponent<OwnerProps & ${TM_FILENAME_BASE}DependProps, {}> {",
" render () {",
" return (",
" <WrappedComponent {...this.props} />",
" )",
" }",
" }",
"}"
],
"description": "create HOC"
},
"FC": {
"prefix": "fc",
"body": [
"${2:export }interface ${1:${TM_FILENAME_BASE}}Props {}",
"",
"${2:export }const ${1:${TM_FILENAME_BASE}}: React.FC<${1:${TM_FILENAME_BASE}}Props> = ({}) => {",
" return ${0:null}",
"}",
"${1:${TM_FILENAME_BASE}}.displayName = \"${1:${TM_FILENAME_BASE}}\""
]
},
"FCNP": {
"prefix": "fcnp",
"body": [
"${2:export }const ${1:${TM_FILENAME_BASE}}: React.FC = () => {",
" return ${0:null}",
"}",
"${1:${TM_FILENAME_BASE}}.displayName = \"${1:${TM_FILENAME_BASE}}\""
]
}
}
{
"Vue_Temp": {
"prefix": "vue",
"body": [
"<template>",
" <div></div>",
"</template>",
"<script lang=\"ts\">",
"import { Component, Vue } from 'vue-property-decorator'",
"@Component({})",
"export default class ${TM_FILENAME_BASE} extends Vue {}",
"</script>",
"<style scoped>",
"</style>"
],
"description": "create Vue Class"
}
}
@ekoneko
Copy link
Author

ekoneko commented Apr 7, 2023

It can change ${TM_FILENAME_BASE} to ${TM_FILENAME_BASE/(^|_)([a-z])/${2:/upcase}/g} for file which named lowercase with underscore, like: a_b.tsx

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