Skip to content

Commit 21504b9

Browse files
authored
Merge pull request xabikos#44 from RusinovAnton/upgrade-lifecycle-hooks
Update lifecycle hooks snippets
2 parents 544d515 + 33b59c0 commit 21504b9

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ Below is a list of all available snippets and the triggers of each one. The **
6262
| `cwup→` | `componentWillUpdate method` |
6363
| `cdup→` | `componentDidUpdate method` |
6464
| `cwun→` | `componentWillUnmount method` |
65+
| `gsbu→` | `getSnapshotBeforeUpdate method` |
66+
| `gdsfp→` | `static getDerivedStateFromProps method` |
67+
| `cdc→` | `componentDidCatch method` |
6568
| `ren→` | `render method` |
6669
| `sst→` | `this.setState with object as parameter` |
6770
| `ssf→` | `this.setState with function as parameter` |

snippets/snippets.json

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"componentWillReceiveProps": {
8585
"prefix": "cwr",
8686
"body": "componentWillReceiveProps(nextProps) {\n\t$0\n}\n",
87-
"description": "Invoked when a component is receiving new props. This method is not called for the initial render."
87+
"description": "Invoked when a component is receiving new props. This method is not called for the initial render. [DEPRECATION NOTE]: This method is deprecated in React 16.3"
8888
},
8989

9090
"shouldComponentUpdate": {
@@ -96,7 +96,7 @@
9696
"componentWillUpdate": {
9797
"prefix": "cwup",
9898
"body": "componentWillUpdate(nextProps, nextState) {\n\t$0\n}\n",
99-
"description": "Invoked immediately before rendering when new props or state are being received."
99+
"description": "Invoked immediately before rendering when new props or state are being received. [DEPRECATION NOTE]: This method is deprecated in React 16.3"
100100
},
101101

102102
"componentDidUpdate": {
@@ -298,5 +298,20 @@
298298
"prefix": "ptshr",
299299
"body": "PropTypes.shape({\n\t$0\n}).isRequired,",
300300
"description": "An object taking on a particular shape required"
301+
},
302+
"getSnapshotBeforeUpdate": {
303+
"prefix": "gsbu",
304+
"body": "getSnapshotBeforeUpdate(prevProps, prevState) {\n\t$0\n}\n",
305+
"description": "Invoked right before the most recently rendered output is committed to e.g. the DOM. It enables your component to capture current values"
306+
},
307+
"getDerivedStateFromProps": {
308+
"prefix": "gdsfp",
309+
"body": "static getDerivedStateFromProps(nextProps, prevState) {\n\t$0\n}\n",
310+
"description": "Invoked after a component is instantiated as well as when it receives new props."
311+
},
312+
"componentDidCatch": {
313+
"prefix": "cdc",
314+
"body": "componentDidCatch(error, info) {\n\t$0\n}\n",
315+
"description": "Error boundaries catch errors during rendering, in lifecycle methods, and in constructors of the whole tree below them."
301316
}
302317
}

0 commit comments

Comments
 (0)