Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3148d38

Browse files
nathanchapmananthonynichols
andauthored
Add react snippets for javascript and typescript (nathanchapman#13)
Co-authored-by: Anthony Nichols <hi@anthonynichols.me>
1 parent c28944a commit 3148d38

File tree

3 files changed

+173
-5
lines changed

3 files changed

+173
-5
lines changed

β€ŽREADME.mdβ€Ž

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var ${0}
3333
##### `v=β‡₯` var assignment
3434

3535
```javascript
36-
var ${1:name} = ${2:value};
36+
var ${1:name} = ${2:value}
3737
```
3838

3939
##### `lβ‡₯` let statement
@@ -45,13 +45,13 @@ let ${0}
4545
##### `l=β‡₯` let assignment
4646

4747
```javascript
48-
let ${1:name} = ${2:value};
48+
let ${1:name} = ${2:value}
4949
```
5050

5151
##### `dl=β‡₯` destructuring let assignment
5252

5353
```javascript
54-
let {${1:name}} = ${2:value};
54+
let {${1:name}} = ${2:value}
5555
```
5656

5757
##### `coβ‡₯` const statement
@@ -63,13 +63,13 @@ const ${0}
6363
##### `co=β‡₯` const assignment
6464

6565
```javascript
66-
const ${1:name} = ${2:value};
66+
const ${1:name} = ${2:value}
6767
```
6868

6969
##### `dco=β‡₯` destructuring const assignment
7070

7171
```javascript
72-
const {${1:name}} = ${2:value};
72+
const {${1:name}} = ${2:value}
7373
```
7474

7575
#### Flow Control
@@ -755,3 +755,37 @@ process.nextTick(() => {
755755
```javascript
756756
'use strict'
757757
```
758+
759+
#### React (JS)
760+
761+
##### `propTypesβ‡₯`
762+
763+
```javascript
764+
static propTypes = {0ドル}
765+
```
766+
767+
##### `defaultPropsβ‡₯`
768+
769+
```javascript
770+
static defaultProps = {0ドル}
771+
```
772+
773+
##### `getDerivedStateFromPropsβ‡₯`
774+
775+
```javascript
776+
static getDerivedStateFromProps(${1:nextProps}, ${2:prevState}) {0ドル}
777+
```
778+
779+
#### React (TS)
780+
781+
##### `defaultPropsβ‡₯`
782+
783+
```typescript
784+
static defaultProps: Partial<${1:${TM_FILENAME_BASE}Props}> = {0ドル}
785+
```
786+
787+
##### `getDerivedStateFromPropsβ‡₯`
788+
789+
```typescript
790+
static getDerivedStateFromProps(${1:nextProps}: ${3:${TM_FILENAME_BASE}${2:Props}}, ${4:prevState}: ${6:${TM_FILENAME_BASE}${5:State}}): Partial<${6:${TM_FILENAME_BASE}${5:State}}> {0ドル}
791+
```

β€Žsnippets/jsx.jsonβ€Ž

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,5 +473,73 @@
473473
"prefix": "us",
474474
"body": "'use strict'",
475475
"description": "insert 'use strict' statement"
476+
},
477+
"component static prop types": {
478+
"prefix": "propTypes",
479+
"body": "static propTypes = {0ドル}",
480+
"description": "Component Static Prop Types"
481+
},
482+
"component static default props": {
483+
"prefix": "defaultProps",
484+
"body": "static defaultProps = {0ドル}",
485+
"description": "Component Static Default Props"
486+
},
487+
"component static get derived state from props": {
488+
"prefix": "getDerivedStateFromProps",
489+
"body": "static getDerivedStateFromProps(${1:nextProps}, ${2:prevState}) {0ドル}",
490+
"description": "Component Static Get Derived State From Props"
491+
},
492+
"component set state": {
493+
"prefix": "setState",
494+
"body": "this.setState(1ドル)0ドル"
495+
},
496+
"component constructor": {
497+
"prefix": "constructor",
498+
"body": [
499+
"constructor(${1:props}) {",
500+
"\tsuper(${1:props})",
501+
"",
502+
"\t4ドル",
503+
"}"
504+
]
505+
},
506+
"component will mount": {
507+
"prefix": "componentWillMount",
508+
"body": "componentWillMount() {0ドル}",
509+
"description": "DEPRECATION WARNING [v16.3]: Use `componentDidMount` instead."
510+
},
511+
"component did mount": {
512+
"prefix": "componentDidMount",
513+
"body": "componentDidMount() {0ドル}"
514+
},
515+
"component will receive props": {
516+
"prefix": "componentWillReceiveProps",
517+
"body": "componentWillReceiveProps(${1:nextProps}) {0ドル}",
518+
"description": "DEPRECATION WARNING [v16.3]: Use `static getDerivedStateFromProps` instead."
519+
},
520+
"should component update": {
521+
"prefix": "shouldComponentUpdate",
522+
"body": "shouldComponentUpdate(${1:nextProps}, ${2:nextState}) {0ドル}"
523+
},
524+
"component will update": {
525+
"prefix": "componentWillUpdate",
526+
"body": "componentWillUpdate(${1:nextProps}, ${2:nextState}) {0ドル}",
527+
"description": "DEPRECATION WARNING [v16.3]: Use `componentDidUpdate` instead."
528+
},
529+
"component did update": {
530+
"prefix": "componentDidUpdate",
531+
"body": "componentDidUpdate(${1:nextProps}, ${2:state}) {0ドル}"
532+
},
533+
"component will unmount": {
534+
"prefix": "componentWillUnmount",
535+
"body": "componentWillUnmount() {0ドル}"
536+
},
537+
"component did catch": {
538+
"prefix": "componentDidCatch",
539+
"body": "componentDidCatch(${1:error}, ${2:errorInfo}) {0ドル}"
540+
},
541+
"component render": {
542+
"prefix": "render",
543+
"body": ["render() {", "\treturn (0ドル)", "}"]
476544
}
477545
}

β€Žsnippets/tsx.jsonβ€Ž

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,5 +473,71 @@
473473
"prefix": "us",
474474
"body": "'use strict'",
475475
"description": "insert 'use strict' statement"
476+
},
477+
"component static prop types": {
478+
"prefix": "propTypes",
479+
"body": "static propTypes = {0ドル}",
480+
"description": "Component Static Prop Types"
481+
},
482+
"component static default props": {
483+
"prefix": "defaultProps",
484+
"body": "static defaultProps: Partial<${1:${TM_FILENAME_BASE}Props}> = {0ドル}"
485+
},
486+
"component static get derived state from props": {
487+
"prefix": "getDerivedStateFromProps",
488+
"body": "static getDerivedStateFromProps(${1:nextProps}: ${3:${TM_FILENAME_BASE}${2:Props}}, ${4:prevState}: ${6:${TM_FILENAME_BASE}${5:State}}): Partial<${6:${TM_FILENAME_BASE}${5:State}}> {0ドル}"
489+
},
490+
"component set state": {
491+
"prefix": "setState",
492+
"body": "this.setState(1ドル)0ドル"
493+
},
494+
"component constructor": {
495+
"prefix": "constructor",
496+
"body": [
497+
"constructor(${1:props}: ${3:${TM_FILENAME_BASE}${2:Props}}) {",
498+
"\tsuper(${1:props})",
499+
"",
500+
"\t4ドル",
501+
"}"
502+
]
503+
},
504+
"component will mount": {
505+
"prefix": "componentWillMount",
506+
"body": "componentWillMount() {0ドル}",
507+
"description": "DEPRECATION WARNING [v16.3]: Use `componentDidMount` instead."
508+
},
509+
"component did mount": {
510+
"prefix": "componentDidMount",
511+
"body": "componentDidMount() {0ドル}"
512+
},
513+
"component will receive props": {
514+
"prefix": "componentWillReceiveProps",
515+
"body": "componentWillReceiveProps(${1:nextProps}: ${3:${TM_FILENAME_BASE}${2:Props}}) {0ドル}",
516+
"description": "DEPRECATION WARNING [v16.3]: Use `static getDerivedStateFromProps` instead."
517+
},
518+
"should component update": {
519+
"prefix": "shouldComponentUpdate",
520+
"body": "shouldComponentUpdate(${1:nextProps}: ${3:${TM_FILENAME_BASE}${2:Props}}, ${4:nextState}: ${6:${TM_FILENAME_BASE}${5:State}}) {0ドル}"
521+
},
522+
"component will update": {
523+
"prefix": "componentWillUpdate",
524+
"body": "componentWillUpdate(${1:nextProps}: ${3:${TM_FILENAME_BASE}${2:Props}}, ${4:nextState}: ${6:${TM_FILENAME_BASE}${5:State}}) {0ドル}",
525+
"description": "DEPRECATION WARNING [v16.3]: Use `componentDidUpdate` instead."
526+
},
527+
"component did update": {
528+
"prefix": "componentDidUpdate",
529+
"body": "componentDidUpdate(${1:nextProps}: ${3:${TM_FILENAME_BASE}${2:Props}}, ${4:nextState}: ${6:${TM_FILENAME_BASE}${5:State}}) {0ドル}"
530+
},
531+
"component will unmount": {
532+
"prefix": "componentWillUnmount",
533+
"body": "componentWillUnmount() {0ドル}"
534+
},
535+
"component did catch": {
536+
"prefix": "componentDidCatch",
537+
"body": "componentDidCatch(${1:error}: Error, ${2:errorInfo}: React.ErrorInfo) {0ドル}"
538+
},
539+
"component render": {
540+
"prefix": "render",
541+
"body": ["render() {", "\treturn (0ドル)", "}"]
476542
}
477543
}

0 commit comments

Comments
(0)

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /