Skip to content

Commit f22811a

Browse files
authored
Merge pull request #20 from Kira272921/docs/readme
docs: add more snippets to the readme
2 parents e1a216f + 7db5af4 commit f22811a

File tree

5 files changed

+71
-68
lines changed

5 files changed

+71
-68
lines changed

README.md

Lines changed: 66 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,86 @@ NextJS and React Snippets with TypeScript support as well!🚀
1414

1515
### JavaScript
1616

17-
1. `rafce` (React Functional Component)
17+
1. `rimr` (Import React)
18+
19+
```jsx
20+
import React from 'react';
21+
```
22+
23+
2. `rimrd` (Import ReactDOM)
24+
25+
```jsx
26+
import ReactDOM from 'react-dom';
27+
```
28+
29+
3. `rimrs` (Import React and useState)
30+
31+
```jsx
32+
import React, { useState } from 'react';
33+
```
34+
35+
4. `rimrse` (Import React, useState and useEffect)
36+
37+
```jsx
38+
import React, { useState, useEffect} from 'react';
39+
```
40+
41+
5. `rfce` (React functional component)
1842

1943
```jsx
2044
const Component = () => {
2145
return <div></div>;
22-
};
46+
}
2347
export default Component;
2448
```
2549

50+
6. `rue` (React useEffect)
51+
52+
```jsx
53+
useEffect(() => {
54+
55+
}, []);
56+
```
57+
58+
7. `rus` (React useState)
59+
60+
```jsx
61+
const [state, setState] = useState(initialValue);
62+
```
63+
64+
8. `ruc` (React useContext)
65+
66+
```jsx
67+
const value = useContext(myContext);
68+
```
69+
70+
9. `rur` (React useRef)
71+
72+
```jsx
73+
const refContainer = useRef(initialValue);
74+
```
75+
2676
### TypeScript
2777

28-
2. `rafect` (React Functional Component with Types)
78+
1. `rfcet` (React functional component Typescript)
2979

30-
```tsx
31-
import { FC } from "react";
32-
interface Props {}
33-
const Component: FC<Props> = () => {
34-
return <div></div>;
35-
};
36-
export default Component;
37-
```
80+
```tsx
81+
import React from "react";
82+
83+
interface Props {}
84+
85+
function Component({}: Props) {
86+
return <div></div>;
87+
}
88+
89+
export default Component;
90+
```
3891

3992
## NextJS
4093

4194
### JavaScript
4295

43-
<<<<<<< HEAD
44-
1. `nssr` (Get Server Side Props Next.js)
45-
=======
4696
1. `nssr` (Next.js Get Server Side Props Typescript)
47-
>>>>>>> 5f7082e97c62b0d190ff1375a6a840db993a53c2
4897

4998
```jsx
5099
export const getServerSideProps = async (context) => {
@@ -54,11 +103,7 @@ NextJS and React Snippets with TypeScript support as well!🚀
54103
};
55104
```
56105

57-
<<<<<<< HEAD
58-
2. `nssg` (Get Static Props Next.js)
59-
=======
60106
2. `nssg` (Next.js Get Static Props Typescript)
61-
>>>>>>> 5f7082e97c62b0d190ff1375a6a840db993a53c2
62107

63108
```jsx
64109
export const getStaticProps = async (context) => {
@@ -70,23 +115,15 @@ NextJS and React Snippets with TypeScript support as well!🚀
70115

71116
### TypeScript
72117

73-
<<<<<<< HEAD
74-
1. `nssrt` (Get Server Side Props Next.js)
75-
=======
76118
1. `nssrt` (Next.js Get Server Side Props Typescript)
77-
>>>>>>> 5f7082e97c62b0d190ff1375a6a840db993a53c2
78119

79120
```tsx
80121
export const getServerSideProps: GetServerSideProps = async (context) => {
81122
return { props: {} };
82123
};
83124
```
84125

85-
<<<<<<< HEAD
86-
2. `nssgt` (Get Static Props Next.js)
87-
=======
88126
2. `nssgt` (Next.js Get Static Props Typescript)
89-
>>>>>>> 5f7082e97c62b0d190ff1375a6a840db993a53c2
90127

91128
```tsx
92129
export const getStaticProps: getStaticProps = async (context) => {
@@ -102,11 +139,7 @@ NextJS and React Snippets with TypeScript support as well!🚀
102139
};
103140
```
104141

105-
<<<<<<< HEAD
106-
3) `npaget` (NextPage component with NextPage type)
107-
=======
108-
3) `npt` (Next.js Page Typescript)
109-
>>>>>>> 5f7082e97c62b0d190ff1375a6a840db993a53c2
142+
4. `npt` (Next.js Page Typescript)
110143

111144
```tsx
112145
import type { NextPage } from "next";
@@ -116,11 +149,7 @@ NextJS and React Snippets with TypeScript support as well!🚀
116149
export default Page;
117150
```
118151

119-
<<<<<<< HEAD
120-
4) `nct` (Next JS Component with NextComponentType and Props)
121-
=======
122-
4) `nct` (Next.js Component Typescript)
123-
>>>>>>> 5f7082e97c62b0d190ff1375a6a840db993a53c2
152+
5. `nct` (Next.js Component Typescript)
124153

125154
```tsx
126155
import type { NextComponentType, NextPageContext } from "next";

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "nextreactsnippets",
2+
"name": "react-nextjs-snippets",
33
"displayName": "Next.js and React Snippets",
44
"description": "This is an extension for Next.js and React Snippets with ts support as well!",
55
"version": "0.4.1",

snippets/next-javascript.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"ssr": {
2+
"nssr": {
33
"prefix": "nssr",
44
"body": [
55
"export const getServerSideProps = async context => {",
@@ -11,7 +11,7 @@
1111
],
1212
"description": "Next.js Get Server Side Props Typescript"
1313
},
14-
"ssg": {
14+
"nssg": {
1515
"prefix": "nssg",
1616
"body": [
1717
"export const getStaticProps = async context => {",

snippets/react-javascript.json

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"Import React": {
3-
"prefix": "rim",
3+
"prefix": "rimr",
44
"body": ["import React from 'react';"],
55
"description": "Import React"
66
},
77
"Import ReactDOM": {
8-
"prefix": "rird",
8+
"prefix": "rimrd",
99
"body": ["import ReactDOM from 'react-dom';"],
1010
"description": "Import ReactDOM"
1111
},
@@ -19,21 +19,6 @@
1919
"body": ["import React, { useState, useEffect} from 'react';"],
2020
"description": "Import React, useState and useEffect"
2121
},
22-
"rfce": {
23-
"prefix": "rfce",
24-
"body": [
25-
"import React from 'react'",
26-
"",
27-
"function ${1:${TM_FILENAME_BASE}}() {",
28-
" return (",
29-
" <div></div>",
30-
" )",
31-
"}",
32-
"",
33-
"export default ${1:${TM_FILENAME_BASE}}"
34-
],
35-
"description": "React Functional Component"
36-
},
3722
"React functional component": {
3823
"prefix": "rfc",
3924
"body": [

snippets/react-typescript.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,5 @@
1414
""
1515
],
1616
"description": "React functional component Typescript"
17-
},
18-
"React functional component": {
19-
"prefix": "rfc",
20-
"body": [
21-
"const ${1:${TM_FILENAME_BASE}} = () => {",
22-
" return <div></div>;",
23-
"};",
24-
"export default ${1:${TM_FILENAME_BASE}};",
25-
""
26-
],
27-
"description": "React functional component"
2817
}
2918
}

0 commit comments

Comments
 (0)