forked from QwikDev/qwik
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qwik.code-snippets
97 lines (97 loc) · 2.06 KB
/
qwik.code-snippets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
{
"Qwik component": {
"scope": "typescriptreact",
"prefix": "q:component w/props",
"description": "Qwik component w/ props",
"body": [
"export interface ${1:${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}}Props {",
" $2",
"}",
"",
"export const $1 = component$((props: $1Props) => {",
" const state = useStore({",
" $3",
" });",
" ",
" return <${4:button} on${5:Click}$={(${6:e}) => {$7}}>$8</${4}>",
"});"
]
},
"Qwik component (simple)": {
"scope": "javascriptreact,typescriptreact",
"prefix": "q:component simple",
"description": "Simple Qwik component",
"body": [
"export const ${1:${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}} = component$(() => {",
" return <${2:button}>$4</$2>",
"});"
]
},
"Qwik state": {
"scope": "javascriptreact,typescriptreact",
"prefix": "q:useStore$",
"description": "useStore() declaration",
"body": [
"const ${1:state} = useStore({",
" $2",
"});",
"$0"
]
},
"$ hook": {
"scope": "javascriptreact,typescriptreact",
"prefix": "q:$",
"description": "$() function hook",
"body": [
"$(() => {",
" $0",
"});",
""
]
},
"useClientEffect": {
"scope": "javascriptreact,typescriptreact",
"prefix": "q:useClientEffect",
"description": "useClientEffect$() function hook",
"body": [
"useClientEffect$(({ track }) => {",
" $0",
"});",
""
]
},
"useTask": {
"scope": "javascriptreact,typescriptreact",
"prefix": "q:useTask",
"description": "useTask$() function hook",
"body": [
"useTask$(({ track }) => {",
" track($1);",
" $0",
"});",
""
]
},
"useResource": {
"scope": "javascriptreact,typescriptreact",
"prefix": "q:useResource$",
"description": "useResource$() declaration",
"body": [
"const $1 = useResource$(({ track, previous, cleanup }) => {",
" $0",
"});",
""
]
},
"useServerMount": {
"scope": "javascriptreact,typescriptreact",
"prefix": "q:useServerMount",
"description": "useServerMount$() function hook",
"body": [
"useServerMount$(() => {",
" $0",
"});",
""
]
}
}