Skip to content

Commit 06d4d4f

Browse files
authored
fix: clean up all the snippets (#40)
1 parent fe7372d commit 06d4d4f

File tree

5 files changed

+126
-82
lines changed

5 files changed

+126
-82
lines changed

packages/vscode/README.md

Lines changed: 58 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -45,33 +45,33 @@
4545
export default Component;
4646
```
4747

48-
6. `rue` (React useEffect)
48+
6. `rue` (useEffect hook)
4949

5050
```jsx
5151
useEffect(() => {}, []);
5252
```
5353

54-
7. `rus` (React useState)
54+
7. `rus` (useState hook)
5555

5656
```jsx
5757
const [state, setState] = useState(initialValue);
5858
```
5959

60-
8. `ruc` (React useContext)
60+
8. `ruc` (useContext hook)
6161

6262
```jsx
6363
const value = useContext(myContext);
6464
```
6565

66-
9. `rur` (React useRef)
66+
9. `rur` (useRef hook)
6767

6868
```jsx
6969
const refContainer = useRef(initialValue);
7070
```
7171

7272
### TypeScript
7373

74-
1. `rfcet` (React functional component Typescript)
74+
1. `rfcet` (React functional component)
7575

7676
```tsx
7777
import React from "react";
@@ -85,11 +85,35 @@
8585
export default Component;
8686
```
8787

88+
2. `ruet` (useEffect hook)
89+
90+
```tsx
91+
useEffect(() => {}, []);
92+
```
93+
94+
3. `rust` (useState hook)
95+
96+
```tsx
97+
const [state, setState] = useState(initialValue);
98+
```
99+
100+
4. `ruct` (useContext hook)
101+
102+
```tsx
103+
const value = useContext(myContext);
104+
```
105+
106+
5. `rurt` (useRef hook)
107+
108+
```tsx
109+
const refContainer = useRef(initialValue);
110+
```
111+
88112
## NextJS
89113

90114
### JavaScript
91115

92-
1. `nssr` (Next.js Get Server Side Props)
116+
1. `ngss` (Next.js get server side props)
93117

94118
```jsx
95119
export const getServerSideProps = async (context) => {
@@ -99,7 +123,7 @@
99123
};
100124
```
101125

102-
2. `nssg` (Next.js Get Static Props)
126+
2. `ngsp` (Next.js get static props)
103127

104128
```jsx
105129
export const getStaticProps = async (context) => {
@@ -109,7 +133,7 @@
109133
};
110134
```
111135

112-
3. `ncapp` (Next Custom App)
136+
3. `ncapp` (Next.js custom app)
113137

114138
```jsx
115139
const MyApp = ({ Component, pageProps }) => {
@@ -119,7 +143,7 @@
119143
export default MyApp;
120144
```
121145

122-
4. `ncdoc` (Next Custom Document)
146+
4. `ncdoc` (Next.js custom document)
123147

124148
```jsx
125149
import Document, { Html, Main, NextScript } from "next/document";
@@ -137,7 +161,7 @@
137161
export default Document;
138162
```
139163

140-
5. `ngsp` (Next.js Get Static Path Javascript)
164+
5. `ngspa` (Next.js get static path)
141165

142166
```jsx
143167
export const getStaticPaths = async () => {
@@ -150,41 +174,41 @@
150174

151175
### TypeScript
152176

153-
1. `nssrt` (Next.js Get Server Side Props Typescript)
177+
1. `ngsst` (Next.js get server side props)
154178

155179
```tsx
156180
export const getServerSideProps: GetServerSideProps = async (context) => {
157181
return { props: {} };
158182
};
159183
```
160184

161-
2. `nssgt` (Next.js Get Static Props Typescript)
185+
2. `ngspt` (Next.js get static props)
162186

163187
```tsx
164188
export const getStaticProps: getStaticProps = async (context) => {
165189
return { props: {} };
166190
};
167191
```
168192

169-
3. `ngip` (Get Initial Props in Next.js)
193+
3. `npt` (Next.js page)
170194

171195
```tsx
172-
Page.getInitialProps = async (context) => {
173-
return { props: {} };
196+
import type { NextPage } from "next";
197+
const Page: NextPage = () => {
198+
return <></>;
174199
};
200+
export default Page;
175201
```
176202

177-
4. `npt` (Next.js Page Typescript)
203+
4. `ngipt` (Next.js get initial props)
178204

179205
```tsx
180-
import type { NextPage } from "next";
181-
const Page: NextPage = () => {
182-
return <></>;
206+
Page.getInitialProps = async (context) => {
207+
return { props: {} };
183208
};
184-
export default Page;
185209
```
186210

187-
5. `nct` (Next.js Component Typescript)
211+
5. `nct` (Next.js component)
188212

189213
```tsx
190214
import type { NextComponentType, NextPageContext } from "next";
@@ -197,7 +221,18 @@
197221
export default Component;
198222
```
199223

200-
6. `ncappt` (Next Custom App Typescript)
224+
6. `ngspat` (Next.js Get Static Path Typescript)
225+
226+
```tsx
227+
export const getStaticPaths: GetStaticPaths = async () => {
228+
return {
229+
paths:[${1}],
230+
fallback:false
231+
};
232+
}
233+
```
234+
235+
7. `ncappt` (Next.js custom app)
201236

202237
```tsx
203238
const MyApp = ({ Component, pageProps }) => {
@@ -206,7 +241,7 @@
206241
export default MyApp;
207242
```
208243

209-
7. `ncdoct`(Next Custom Document Typescript)
244+
8. `ncdoct`(Next.js custom document)
210245

211246
```tsx
212247
import Document, { Html, Main, NextScript } from "next/document";
@@ -224,13 +259,3 @@
224259
export default Document;
225260
```
226261

227-
8. `ngspt` (Next.js Get Static Path Typescript)
228-
229-
```tsx
230-
export const getStaticPaths: GetStaticPaths = async () => {
231-
return {
232-
paths:[${1}],
233-
fallback:false
234-
};
235-
}
236-
```

packages/vscode/snippets/next-javascript.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
{
2-
"nssr": {
3-
"prefix": "nssr",
2+
"ngss": {
3+
"prefix": "ngss",
44
"body": [
55
"export const getServerSideProps = async context => {",
66
" return {",
77
" props: {},",
88
" };",
99
"};"
1010
],
11-
"description": "Next.js Get Server Side Props"
11+
"description": "JavaScript: Next.js get server side props"
1212
},
1313

14-
"nssg": {
15-
"prefix": "nssg",
14+
"ngsp": {
15+
"prefix": "ngsp",
1616
"body": [
1717
"export const getStaticProps = async context => {",
1818
" return {",
1919
" props: {},",
2020
" };",
2121
"};"
2222
],
23-
"description": "Next.js Get Static Props"
23+
"description": "JavaScript: Next.js get static props"
2424
},
25-
"ngsp": {
26-
"prefix": "ngsp",
25+
"ngspa": {
26+
"prefix": "ngspa",
2727
"body": [
2828
"export const getStaticPaths = async () => {",
2929
" return {",
@@ -32,7 +32,7 @@
3232
" }",
3333
"}"
3434
],
35-
"description": "Next.js Get Static Path Javascript"
35+
"description": "JavaScript: Next.js get static path"
3636
},
3737
"ncapp": {
3838
"prefix": "ncapp",
@@ -43,7 +43,7 @@
4343
"",
4444
"export default MyApp;"
4545
],
46-
"description": "Next Custom App"
46+
"description": "JavaScript: Next.js custom app"
4747
},
4848

4949
"ncdoc": {
@@ -64,6 +64,6 @@
6464
"",
6565
"export default Document;"
6666
],
67-
"description": "Next Custom Document"
67+
"description": "JavaScript: Next.js custom document"
6868
}
6969
}

packages/vscode/snippets/next-typescript.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
{
2-
"nssrt": {
3-
"prefix": "nssrt",
2+
"ngsst": {
3+
"prefix": "ngsst",
44
"body": [
55
"export const getServerSideProps: GetServerSideProps = async context => {",
66
" return {",
77
" props: {},",
88
" };",
99
"};"
1010
],
11-
"description": "Next.js Get Server Side Props Typescript"
11+
"description": "Typescript: Next.js get server side props"
1212
},
1313

14-
"nssgt": {
15-
"prefix": "nssgt",
14+
"ngspt": {
15+
"prefix": "ngsp",
1616
"body": [
1717
"export const getStaticProps: getStaticProps = async context => {",
1818
" return {",
1919
" props: {},",
2020
" };",
2121
"};"
2222
],
23-
"description": "Next.js Get Static Props Typescript"
23+
"description": "TypeScript: Next.js get static props"
2424
},
2525

2626
"npt": {
@@ -37,19 +37,19 @@
3737
"",
3838
"export default ${1:${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}}"
3939
],
40-
"description": "Next.js Page Typescript"
40+
"description": "Typescript: Next.js page"
4141
},
4242

43-
"ngip": {
44-
"prefix": "ngip",
43+
"ngipt": {
44+
"prefix": "ngipt",
4545
"body": [
4646
"${1:${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}}.getInitialProps = async context => {",
4747
" return {",
4848
" ",
4949
" };",
5050
"};"
5151
],
52-
"description": "Next.js Get Initial Props"
52+
"description": "TypeScript: Next.js get initial props"
5353
},
5454

5555
"nct": {
@@ -69,10 +69,10 @@
6969
"",
7070
"export default ${1:${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}}"
7171
],
72-
"description": "Next.js Component Typescript"
72+
"description": "Typescript: Next.js component"
7373
},
74-
"ngspt": {
75-
"prefix": "ngspt",
74+
"ngspat": {
75+
"prefix": "ngspat",
7676
"body": [
7777
"export const getStaticPaths: GetStaticPaths = async () => {",
7878
" return {",
@@ -81,7 +81,7 @@
8181
" }",
8282
"}"
8383
],
84-
"description": "Next.js Get Static Path Typescript"
84+
"description": "Typescript: Next.js get static path"
8585
},
8686
"ncappt": {
8787
"prefix": "ncappt",
@@ -92,7 +92,7 @@
9292
"",
9393
"export default MyApp;"
9494
],
95-
"description": "Next Custom App Typescript"
95+
"description": "Typescript: Next.js custom app"
9696
},
9797

9898
"ncdoct": {
@@ -113,6 +113,6 @@
113113
"",
114114
"export default Document;"
115115
],
116-
"description": "Next Custom Document Typescript"
116+
"description": "Typescript: Next.js custom document"
117117
}
118118
}

0 commit comments

Comments
 (0)