Skip to content

Instantly share code, notes, and snippets.

@mathurs
Created July 9, 2018 16:02
Show Gist options
  • Select an option

  • Save mathurs/346b8548f9cbcb3547fd71fb56b5808a to your computer and use it in GitHub Desktop.

Select an option

Save mathurs/346b8548f9cbcb3547fd71fb56b5808a to your computer and use it in GitHub Desktop.
VSCode User Snippet For React Components
{
// Place your snippets for javascriptreact 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:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"Class Component": {
"prefix": "reactcc",
"body": [
"import React, { Component } from 'react';",
"import {",
" Row, Col, Alert",
"} from 'reactstrap';",
"",
"class ${1:filename} extends Component{",
" constructor(props){",
" super(props);",
" this.state = {",
" }",
" }",
"",
" render(){",
" return (",
" );",
" }",
"}",
"",
"export default ${1:filename}",
],
"description": "Class Component Template"
},
"Redux Component": {
"prefix": "reactrc",
"body": [
"import React, { Component } from 'react';",
"import {",
" Row, Col, Alert",
"} from 'reactstrap';",
"",
"import { connect } from 'react-redux';",
"",
"var ${1:filename}State = function(state) {",
" return {",
" }",
"}",
"",
"var ${1:filename}Dispatch = function(dispatch) {",
" return {",
" }",
"}",
"",
"class ${1:filename} extends Component{",
" constructor(props){",
" super(props);",
" this.state = {",
" }",
" }",
"",
" render(){",
" return (",
" );",
" }",
"}",
"",
"${1:filename} = connect( ${1:filename}State, ${1:filename}Dispatch )(${1:filename});",
"export default ${1:filename}",
],
"description": "Redux Component Template"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment