@@ -16,125 +16,151 @@ NextJS and React Snippets with TypeScript support as well!🚀
1616
17171 . ` rimr ` (Import React)
1818
19- ``` jsx
20- import React from ' react' ;
21- ```
19+ ``` jsx
20+ import React from " react" ;
21+ ```
2222
23232 . ` rimrd ` (Import ReactDOM)
2424
25- ` ` ` jsx
26- import ReactDOM from ' react-dom' ;
27- ` ` `
25+ ``` jsx
26+ import ReactDOM from " react-dom" ;
27+ ```
2828
29293 . ` rimrs ` (Import React and useState)
3030
31- ` ` ` jsx
32- import React, { useState } from ' react' ;
33- ` ` `
31+ ``` jsx
32+ import React , { useState } from " react" ;
33+ ```
3434
35354 . ` rimrse ` (Import React, useState and useEffect)
3636
37- ` ` ` jsx
38- import React, { useState, useEffect} from ' react' ;
39- ` ` `
37+ ``` jsx
38+ import React , { useState , useEffect } from " react" ;
39+ ```
4040
41415 . ` rfce ` (React functional component)
4242
43- ` ` ` jsx
44- const Component = () => {
45- return <div></div>;
46- }
47- export default Component;
48- ` ` `
43+ ``` jsx
44+ const Component = () => {
45+ return < div>< / div> ;
46+ };
47+ export default Component ;
48+ ```
4949
50506 . ` rue ` (React useEffect)
5151
52- ` ` ` jsx
53- useEffect(() => {
54-
55- }, []);
56- ` ` `
52+ ``` jsx
53+ useEffect (() => {}, []);
54+ ```
5755
58567 . ` rus ` (React useState)
5957
60- ` ` ` jsx
61- const [state, setState] = useState(initialValue);
62- ` ` `
58+ ``` jsx
59+ const [state , setState ] = useState (initialValue);
60+ ```
6361
64628 . ` ruc ` (React useContext)
6563
66- ` ` ` jsx
67- const value = useContext(myContext);
68- ` ` `
64+ ``` jsx
65+ const value = useContext (myContext);
66+ ```
6967
70689 . ` rur ` (React useRef)
7169
72- ` ` ` jsx
73- const refContainer = useRef(initialValue);
74- ` ` `
70+ ``` jsx
71+ const refContainer = useRef (initialValue);
72+ ```
7573
7674### TypeScript
7775
78761 . ` rfcet ` (React functional component Typescript)
7977
80- ` ` ` tsx
81- import React from "react";
78+ ``` tsx
79+ import React from " react" ;
8280
83- interface Props {}
81+ interface Props {}
8482
85- function Component({}: Props) {
86- return <div></div>;
87- }
83+ function Component({}: Props ) {
84+ return <div ></div >;
85+ }
8886
89- export default Component;
90- ` ` `
87+ export default Component ;
88+ ```
9189
9290## NextJS
9391
9492### JavaScript
9593
96- 1. ` nssr` (Next .js Get Server Side Props Typescript )
94+ 1 . ` nssr ` (Next.js Get Server Side Props)
9795
9896 ``` jsx
99- export const getServerSideProps = async ( context) => {
97+ export const getServerSideProps = async context => {
10098 return {
10199 props: {},
102100 };
103101 };
104102 ```
105103
106- 2. ` nssg` (Next .js Get Static Props Typescript )
104+ 2. ` nssg` (Next .js Get Static Props)
107105
108106 ` ` ` jsx
109- export const getStaticProps = async ( context) => {
107+ export const getStaticProps = async context => {
110108 return {
111109 props: {},
112110 };
113111 };
114112 ` ` `
115113
114+ 3. ` ncapp` (Next Custom App)
115+
116+ ` ` ` jsx
117+ const MyApp = ({ Component, pageProps }) => {
118+ return <Component {...pageProps} />;
119+ };
120+
121+ export default MyApp;
122+ ` ` `
123+
124+ 4. ` ncdoc` (Next Custom Document )
125+
126+ ` ` ` jsx
127+ import Document, { Html, Main, NextScript } from "next/_document";
128+ const Document: Document = () => {
129+ return (
130+ <Html lang="en">
131+ <body>
132+ <Main />
133+ <NextScript />
134+ </body>
135+ </Html>
136+ );
137+ };
138+
139+ export default Document;
140+ ` ` `
141+
116142### TypeScript
117143
1181441. ` nssrt` (Next .js Get Server Side Props Typescript)
119145
120146 ` ` ` tsx
121- export const getServerSideProps: GetServerSideProps = async ( context) => {
147+ export const getServerSideProps: GetServerSideProps = async context => {
122148 return { props: {} };
123149 };
124150 ` ` `
125151
1261522. ` nssgt` (Next .js Get Static Props Typescript)
127153
128154 ` ` ` tsx
129- export const getStaticProps: getStaticProps = async ( context) => {
155+ export const getStaticProps: getStaticProps = async context => {
130156 return { props: {} };
131157 };
132158 ` ` `
133159
1341603. ` ngip` (Get Initial Props in Next .js )
135161
136162 ` ` ` tsx
137- Page.getInitialProps = async ( context) => {
163+ Page.getInitialProps = async context => {
138164 return { props: {} };
139165 };
140166 ` ` `
@@ -161,3 +187,30 @@ NextJS and React Snippets with TypeScript support as well!🚀
161187 };
162188 export default Component;
163189 ` ` `
190+
191+ 6. ` ncappt` (Next Custom App Typescript)
192+
193+ ` ` ` tsx
194+ const MyApp = ({ Component, pageProps }) => {
195+ return <Component {...pageProps} />;
196+ };
197+ export default MyApp;
198+ ` ` `
199+
200+ 7. ` ncdoct` (Next Custom Document Typescript)
201+
202+ ` ` ` tsx
203+ import Document, { Html, Main, NextScript } from "next/_document";
204+ const Document: Document = () => {
205+ return (
206+ <Html lang="en">
207+ <body>
208+ <Main />
209+ <NextScript />
210+ </body>
211+ </Html>
212+ );
213+ };
214+
215+ export default Document;
216+ ` ` `
0 commit comments