Skip to content

Instantly share code, notes, and snippets.

@sasha-id
Created September 10, 2022 16:36
Show Gist options
  • Save sasha-id/5c2cbb056d7414436d79552b8bb4525f to your computer and use it in GitHub Desktop.
Save sasha-id/5c2cbb056d7414436d79552b8bb4525f to your computer and use it in GitHub Desktop.
VScode snippets shortcuts for typescript/react, dash docset
cheatsheet do
title 'VSCode snippets' # Will be displayed by Dash in the docset list
docset_file_name 'VSCode-snippets' # Used for the filename of the docset
keyword 'typescript' # Used as the initial search keyword (listed in Preferences > Docsets)
# resources 'resources_dir' # An optional resources folder which can contain images or anything else
introduction 'Snippet shortcuts for vscode' # Optional, can contain Markdown or HTML
# https://github.com/accierro/react-typescript-snippets
category do
id 'React Typescript Snippets' # Must be unique and is used as title of the category
entry do
command 'tfcd→'
name 'Function Component base with Typescript and default export'
end
entry do
command 'tfcp→'
name 'Function Component base with Typescript'
end
entry do
command 'etfc→'
name 'Function Component base with Typescript and named export'
end
entry do
command 'imr→'
name 'Imports React'
end
entry do
command 'sc→'
name 'Imports Styled Components'
end
end
category do
id 'Basic Methods'
entry do
command 'imp→'
name "import moduleName from 'module'"
end
entry do
command 'imn→'
name "import 'module'"
end
entry do
command 'imd→'
name "import { destructuredModule } from 'module'"
end
entry do
command 'ime→'
name "import * as alias from 'module'"
end
entry do
command 'ima→'
name "import { originalName as aliasName} from 'module'"
end
entry do
command 'exp→'
name "export default moduleName"
end
entry do
command 'exd→'
name "export { destructuredModule } from 'module'"
end
entry do
command 'exa→'
name "export { originalName as aliasName} from 'module'"
end
entry do
command 'enf→'
name "export const functionName = (params) => { }"
end
entry do
command 'edf→'
name "export default (params) => { }"
end
entry do
command 'ednf→'
name "export default function functionName(params) { }"
end
entry do
command 'met→'
name "methodName = (params) => { }"
end
entry do
command 'fre→'
name "arrayName.forEach(element => { }"
end
entry do
command 'fof→'
name "for(let itemName of objectName { }"
end
entry do
command 'fin→'
name "for(let itemName in objectName { }"
end
entry do
command 'anfn→'
name "(params) => { }"
end
entry do
command 'nfn→'
name "const functionName = (params) => { }"
end
entry do
command 'dob→'
name "const {propName} = objectToDescruct"
end
entry do
command 'dar→'
name "const [propName] = arrayToDescruct"
end
entry do
command 'sti→'
name "setInterval(() => { }, intervalTime"
end
entry do
command 'sto→'
name "setTimeout(() => { }, delayTime"
end
entry do
command 'prom→'
name "return new Promise((resolve, reject) => { }"
end
entry do
command 'cmmb→'
name "comment block"
end
entry do
command 'cp→'
name "const { } = this.props"
end
entry do
command 'cs→'
name "const { } = this.state"
end
end
category do
id 'React'
entry do
command 'imr→'
name "import React from 'react'"
end
entry do
command 'imrd→'
name "import ReactDOM from 'react-dom'"
end
entry do
command 'imrc→'
name "import React, { Component } from 'react'"
end
entry do
command 'imrpc→'
name "import React, { PureComponent } from 'react'"
end
entry do
command 'imrm→'
name "import React, { memo } from 'react'"
end
entry do
command 'imrr→'
name "import { BrowserRouter as Router, Route, NavLink} from 'react-router-dom'"
end
entry do
command 'imbr→'
name "import { BrowserRouter as Router} from 'react-router-dom'"
end
entry do
command 'imbrc→'
name "import { Route, Switch, NavLink, Link } from react-router-dom'"
end
entry do
command 'imbrr→'
name "import { Route } from 'react-router-dom'"
end
entry do
command 'imbrs→'
name "import { Switch } from 'react-router-dom'"
end
entry do
command 'imbrl→'
name "import { Link } from 'react-router-dom'"
end
entry do
command 'imbrnl→'
name "import { NavLink } from 'react-router-dom'"
end
entry do
command 'imrs→'
name "import React, { useState } from 'react'"
end
entry do
command 'imrse→'
name "import React, { useState, useEffect } from 'react'"
end
entry do
command 'redux→'
name "import { connect } from 'react-redux'"
end
entry do
command 'est→'
name "this.state = { }"
end
entry do
command 'cdm→'
name "componentDidMount = () => { }"
end
entry do
command 'scu→'
name "shouldComponentUpdate = (nextProps, nextState) => { }"
end
entry do
command 'cdup→'
name "componentDidUpdate = (prevProps, prevState) => { }"
end
entry do
command 'cwun→'
name "componentWillUnmount = () => { }"
end
entry do
command 'gdsfp→'
name "static getDerivedStateFromProps(nextProps, prevState) { }"
end
entry do
command 'gsbu→'
name "getSnapshotBeforeUpdate = (prevProps, prevState) => { }"
end
entry do
command 'sst→'
name "this.setState({ })"
end
entry do
command 'ssf→'
name "this.setState((state, props) => return { })"
end
entry do
command 'props→'
name "this.props.propName"
end
entry do
command 'state→'
name "this.state.stateName"
end
entry do
command 'rcontext→'
name "const $1 = React.createContext()"
end
entry do
command 'cref→'
name "this.$1Ref = React.createRef()"
end
entry do
command 'fref→'
name "const ref = React.createRef()"
end
entry do
command 'bnd→'
name "this.methodName = this.methodName.bind(this)"
end
end
category do
id 'PropTypes'
entry do
command 'pta→'
name "PropTypes.array"
end
entry do
command 'ptar→'
name "PropTypes.array.isRequired"
end
entry do
command 'ptb→'
name "PropTypes.bool"
end
entry do
command 'ptbr→'
name "PropTypes.bool.isRequired"
end
entry do
command 'ptf→'
name "PropTypes.func"
end
entry do
command 'ptfr→'
name "PropTypes.func.isRequired"
end
entry do
command 'ptn→'
name "PropTypes.number"
end
entry do
command 'ptnr→'
name "PropTypes.number.isRequired"
end
entry do
command 'pto→'
name "PropTypes.object"
end
entry do
command 'ptor→'
name "PropTypes.object.isRequired"
end
entry do
command 'pts→'
name "PropTypes.string"
end
entry do
command 'ptsr→'
name "PropTypes.string.isRequired"
end
entry do
command 'ptnd→'
name "PropTypes.node"
end
entry do
command 'ptndr→'
name "PropTypes.node.isRequired"
end
entry do
command 'ptel→'
name "PropTypes.element"
end
entry do
command 'ptelr→'
name "PropTypes.element.isRequired"
end
entry do
command 'pti→'
name "PropTypes.instanceOf(name)"
end
entry do
command 'ptir→'
name "PropTypes.instanceOf(name).isRequired"
end
entry do
command 'pte→'
name "PropTypes.oneOf([name])"
end
entry do
command 'pter→'
name "PropTypes.oneOf([name]).isRequired"
end
entry do
command 'ptet→'
name "PropTypes.oneOfType([name])"
end
entry do
command 'ptetr→'
name "PropTypes.oneOfType([name]).isRequired"
end
entry do
command 'ptao→'
name "PropTypes.arrayOf(name)"
end
entry do
command 'ptaor→'
name "PropTypes.arrayOf(name).isRequired"
end
entry do
command 'ptoo→'
name "PropTypes.objectOf(name)"
end
entry do
command 'ptoor→'
name "PropTypes.objectOf(name).isRequired"
end
entry do
command 'ptsh→'
name "PropTypes.shape({ })"
end
entry do
command 'ptshr→'
name "PropTypes.shape({ }).isRequired"
end
entry do
command 'ptany→'
name "PropTypes.any"
end
entry do
command 'ptypes→'
name "static propTypes = {}"
end
end
category do
id 'Console'
entry do
command 'clg→'
name "console.log(object)"
end
entry do
command 'clo→'
name "console.log(`object`, object)"
end
entry do
command 'clj→'
name "console.log(`object`, JSON.stringify(object, null, 2))"
end
entry do
command 'ctm→'
name "console.time(`timeId`)"
end
entry do
command 'cte→'
name "console.timeEnd(`timeId`)"
end
entry do
command 'cas→'
name "console.assert(expression,object)"
end
entry do
command 'ccl→'
name "console.clear()"
end
entry do
command 'cco→'
name "console.count(label)"
end
entry do
command 'cdi→'
name "console.dir"
end
entry do
command 'cer→'
name "console.error(object)"
end
entry do
command 'cgr→'
name "console.group(label)"
end
entry do
command 'cge→'
name "console.groupEnd()"
end
entry do
command 'ctr→'
name "console.trace(object)"
end
entry do
command 'cwa→'
name "console.warn"
end
entry do
command 'cin→'
name "console.info"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment