Skip to content

Commit 8a148fa

Browse files
kbilkisDamian Sznajder
authored and
Damian Sznajder
committed
Add 'bnd' for React method binding
1 parent 57dee8c commit 8a148fa

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Every space inside `{ }` and `( )` means that this is pushed into next line :)
7676
| `rcontext→` | `const ${1:contextName} = React.createContext()` |
7777
| `cref→` | `this.${1:refName}Ref = React.createRef()` |
7878
| `fref→` | `const ref = React.createRef()` |
79+
| `bnd→` | `this.methodName = this.methodName.bind(this)` |
7980

8081
## React Native
8182

snippets/snippets.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,11 @@
561561
"prefix": "state",
562562
"body": "this.state.$0"
563563
},
564+
"bindThis": {
565+
"prefix": "bnd",
566+
"body": "this.${1:methodName} = this.${1:methodName}.bind(this)$0",
567+
"description": "Binds this to a method"
568+
},
564569
// ==============================================================================================
565570
// Redux
566571
"reduxAction": {

0 commit comments

Comments
 (0)