Skip to content

Commit 01d49fa

Browse files
v1.0.0
0 parents  commit 01d49fa

File tree

9 files changed

+170
-0
lines changed

9 files changed

+170
-0
lines changed

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"bracketSpacing": false,
3+
"singleQuote": true,
4+
"tabWidth": 4,
5+
"useTabs": true
6+
}

.vscodeignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.prettierrc
2+
playground.js

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Change Log
2+
3+
## v1.0.0
4+
5+
Initial Set of Hooks
6+
7+
| Trigger | Content |
8+
| --------: | -------------------------- |
9+
| `uref→` | useRef() |
10+
| `ust→` | useState() |
11+
| `ueff→` | useEffect() |
12+
| `ulay→` | useLayoutEffect() |
13+
| `ucon→` | useContext() |
14+
| `ucall→` | useCallback() |
15+
| `umem→` | useMemo() |
16+
| `uimp→` | useImperativeHandle() |
17+
| `ured→` | useReducer() |
18+
| `udebug→` | useDebugValue() |
19+
| `use→` | Generic for selecting hook |

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2021 bryceosterhaus
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Simple React Hooks Snippets
2+
3+
Simple set of snippets for React Hooks.
4+
5+
[React hooks](https://reactjs.org/docs/hooks-reference.html) snippets extension for [Visual Studio Code](https://code.visualstudio.com/).
6+
7+
## Snippets
8+
9+
Below is a list of all available snippets and the triggers of each one. The **** means the `TAB` key.
10+
11+
### Globals
12+
13+
| Trigger | Content |
14+
| --------: | -------------------------- |
15+
| `uref→` | useRef() |
16+
| `ust→` | useState() |
17+
| `ueff→` | useEffect() |
18+
| `ulay→` | useLayoutEffect() |
19+
| `ucon→` | useContext() |
20+
| `ucall→` | useCallback() |
21+
| `umem→` | useMemo() |
22+
| `uimp→` | useImperativeHandle() |
23+
| `ured→` | useReducer() |
24+
| `udebug→` | useDebugValue() |
25+
| `use→` | Generic for selecting hook |

package.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "simple-react-hooks-snippets",
3+
"version": "1.0.0",
4+
"description": "Set of helpful snippets for VSCode for working with React hooks",
5+
"author": "Bryce Osterhaus <[email protected]>",
6+
"license": "MIT",
7+
"publisher": "bryceo",
8+
"displayName": "Simple React Hooks Snippets",
9+
"icon": "react-logo.png",
10+
"engines": {
11+
"vscode": "0.10.x"
12+
},
13+
"repository": {
14+
"type": "git",
15+
"url": "https://github.com/bryceosterhaus/react-hooks-snippets"
16+
},
17+
"categories": [
18+
"Snippets"
19+
],
20+
"contributes": {
21+
"snippets": [
22+
{
23+
"language": "javascriptreact",
24+
"path": "./snippets/snippets.json"
25+
},
26+
{
27+
"language": "javascript",
28+
"path": "./snippets/snippets.json"
29+
},
30+
{
31+
"language": "typescript",
32+
"path": "./snippets/snippets.json"
33+
},
34+
{
35+
"language": "typescriptreact",
36+
"path": "./snippets/snippets.json"
37+
}
38+
]
39+
}
40+
}

playground.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// This file is used for testing snippets

react-logo.png

12.1 KB
Loading

snippets/snippets.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"useRef": {
3+
"body": "const ${1}Ref = React.useRef(${2:null});",
4+
"prefix": "uref"
5+
},
6+
"useState": {
7+
"body": "const [${1}, set${1/(.*)/${1:/capitalize}/}] = React.useState(${2});",
8+
"prefix": "ust"
9+
},
10+
"useEffect": {
11+
"body": ["React.useEffect(() => {", "\t${1}", "}, [${2}]);"],
12+
"prefix": "ueff"
13+
},
14+
"useLayoutEffect": {
15+
"body": ["React.useLayoutEffect(() => {", "\t${1}", "}, [${2}]);"],
16+
"prefix": "ulay"
17+
},
18+
"useContext": {
19+
"body": "const ${1} = React.useContext(${2});",
20+
"prefix": "ucon"
21+
},
22+
"useCallback": {
23+
"body": [
24+
"const ${1} = React.useCallback((${2:args}) => {",
25+
"\t${3}",
26+
"}, [${4}]);"
27+
],
28+
"prefix": "ucall"
29+
},
30+
"useMemo": {
31+
"body": ["const ${1} = React.useMemo(() => {", "\t${2}", "}, [${3}]);"],
32+
"prefix": "umem"
33+
},
34+
"useImperativeHandle": {
35+
"body": [
36+
"React.useImperativeHandle(${1:ref}, () => ({",
37+
"\t${2:focus}: () => {",
38+
"\t\t${3}",
39+
"\t},",
40+
"}));"
41+
],
42+
"prefix": "uimp"
43+
},
44+
"useReducer": {
45+
"body": "const [${1:state}, ${2:dispatch}] = React.useReducer(${3:reducer}, ${4:initialState});",
46+
"prefix": "ured"
47+
},
48+
"useDebugValue": {
49+
"body": "React.useDebugValue(${1});",
50+
"prefix": "udebug"
51+
},
52+
"use*": {
53+
"body": "React.use${1|State,Effect,Ref,Memo,Context,Callback|}(${2});",
54+
"prefix": "use"
55+
}
56+
}

0 commit comments

Comments
 (0)