Skip to content

Commit 18b1fcc

Browse files
committed
updated readme, fixed some snippet issues
1 parent 050f026 commit 18b1fcc

File tree

3 files changed

+66
-60
lines changed

3 files changed

+66
-60
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ React Hooks Snippets is a [Visual Studio Code](https://code.visualstudio.com/) e
3636
| `irh` | `import React` (and common hooks) |
3737
| `urh` | `useRef` |
3838
| `urdh` | `useReducer` |
39-
| `prev` | use previous state|
4039
| `irrh` | import react redux hooks |
4140
| `uss` | `useSelector` |
4241
| `usdf` | `useDispatch` |
@@ -56,7 +55,13 @@ Launch VS Code Extension Marketplace (Ctrl+Shift+X), search for `React Hooks Sni
5655

5756
## Contributing
5857

59-
Submit a pull request with your proposed fixes, changes, and/or improvements and I'll take a look!
58+
There are two ways to contribute:
59+
60+
#### Code
61+
Submit a pull request with your proposed fixes, changes, and/or improvements. All are welcome!
62+
63+
#### Coffee
64+
<a href='https://www.buymeacoffee.com/alduncanson' target='_blank'><img src='https://cdn.buymeacoffee.com/buttons/default-orange.png' alt='Buy Me A Coffee' height='34' width='144'></a>
6065

6166
## License
62-
Usage is provided under the [MIT License](https://opensource.org/licenses/MIT). See LICENSE.txt for the full details.
67+
Usage is provided under the [MIT License](https://opensource.org/licenses/MIT). See [LICENSE.txt](https://github.com/alDuncanson/react-hooks-snippets/blob/master/LICENSE.txt) for the full details.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
"react",
1414
"hooks",
1515
"javascript",
16-
"es6"
16+
"es6",
17+
"snippets",
18+
"snippet"
1719
],
1820
"engines": {
1921
"vscode": "^1.33.0"

snippets/snippets.json

Lines changed: 55 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
{
22
"useState": {
3-
"prefix": "ush",
4-
"body": [
5-
"const [${1}, set${1/(.*)/${1:/capitalize}/}] = useState($2);$0"
6-
],
7-
"description": "React useState() hook"
3+
"prefix": "ush",
4+
"body": [
5+
"const [${1}, set${1/(.*)/${1:/capitalize}/}] = useState($2);$0"
6+
],
7+
"description": "React useState() hook"
88
},
99
"useEffect": {
1010
"prefix": "ueh",
1111
"body": [
1212
"useEffect(() => {",
13-
"\t$1",
14-
"\n\treturn cleanUp = () => {",
15-
"\t\t$2",
16-
"\t}",
13+
"\t$1",
14+
"\n\treturn cleanUp = () => {",
15+
"\t\t$2",
16+
"\t}",
1717
"}, [${3}]);$0"
1818
],
1919
"description": "React useEffect() hook"
@@ -29,10 +29,10 @@
2929
"prefix": "ucbh",
3030
"body": [
3131
"const ${1:memoizedCallback} = useCallback(",
32-
"\t() => {",
33-
"\t\t${2:doSomething}(${3:a}, ${4:b})",
34-
"\t},",
35-
"\t[${5:a}, ${6:b}],",
32+
"\t() => {",
33+
"\t\t${2:doSomething}(${3:a}, ${4:b})",
34+
"\t},",
35+
"\t[${5:a}, ${6:b}],",
3636
");$0"
3737
],
3838
"description": "React useCallback() hook"
@@ -45,48 +45,47 @@
4545
"description": "React useMemo() hook"
4646
},
4747
"import react hooks": {
48-
"prefix": "irh",
49-
"body": ["import React, { useState, useContext, useEffect, useCallback, useMemo } from 'react';"]
50-
},
48+
"prefix": "irh",
49+
"body": [
50+
"import React, { useState, useContext, useEffect, useCallback, useMemo } from 'react';"
51+
]
52+
},
5153
"useRef": {
52-
"prefix": "urh",
53-
"body": [
54-
"const $1 = useRef($2)$0"
55-
],
56-
"description": "React useRef() hook"
57-
},
54+
"prefix": "urh",
55+
"body": [
56+
"const $1 = useRef($2);$0"
57+
],
58+
"description": "React useRef() hook"
59+
},
5860
"useReducer": {
59-
"prefix": "urdh",
60-
"body": [
61-
"const [${1:state},${2: dispatch}] = useReducer(state, action);",
62-
63-
"\n\treturn (",
64-
"\t\t",
65-
"\t);"
66-
67-
],
68-
"description": "React useReducer() hook"
69-
},
70-
"prev state": {
71-
"prefix": "prev",
72-
"body": [ "const prev${1/(.*)/${1:/capitalize}/}Ref = useRef();", "useEffect(() => {", "\tprev${1/(.*)/${1:/capitalize}/}Ref.current = $1;", "});", "const prev$1 = prev${1:/capitalize}/}Ref.current;"]
73-
},
74-
"import react-redux hooks": {
75-
"prefix": "irrh",
76-
"body": ["import { useSelector, useDispatch } from 'react-redux';"]
77-
},
78-
"useSelector": {
79-
"prefix": "uss",
80-
"body": [
81-
"const $1 = useSelector(state => state.$1);"
82-
]
83-
},
84-
"useDispatchFunction": {
85-
"prefix": "usdf",
86-
"body": ["const dispatch = useDispatch();"]
87-
},
88-
"useDispatch": {
89-
"prefix": "usd",
90-
"body": ["const $1 = $2 => dispatch($3);"]
91-
}
92-
}
61+
"prefix": "urdh",
62+
"body": [
63+
"const [${1:state},${2: dispatch}] = useReducer(${3:reducer}, ${4:initialArg}, ${5:init});"
64+
],
65+
"description": "React useReducer() hook"
66+
},
67+
"import react-redux hooks": {
68+
"prefix": "irrh",
69+
"body": [
70+
"import { useSelector, useDispatch } from 'react-redux';"
71+
]
72+
},
73+
"useSelector": {
74+
"prefix": "uss",
75+
"body": [
76+
"const $1 = useSelector(state => state.$1);"
77+
]
78+
},
79+
"useDispatchFunction": {
80+
"prefix": "usdf",
81+
"body": [
82+
"const $1 = useDispatch($2);$3"
83+
]
84+
},
85+
"useDispatch": {
86+
"prefix": "usd",
87+
"body": [
88+
"const $1 = $2 => dispatch($3);"
89+
]
90+
}
91+
}

0 commit comments

Comments
 (0)