Skip to content

Commit 4813f6b

Browse files
authored
Merge pull request #10 from rkazi103/main
feat: added next js typescript component
2 parents 0f4338f + 7da5468 commit 4813f6b

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ NextJS and React Snippets with TypeScript support as well!🚀
2828
2. `rafect` (React Functional Component with Types)
2929

3030
```tsx
31-
import { FC } from 'react';
31+
import { FC } from "react";
3232
interface Props {}
3333
const Component: FC<Props> = () => {
3434
return <div></div>;
@@ -81,9 +81,22 @@ NextJS and React Snippets with TypeScript support as well!🚀
8181
3. `taytay` (NextPage component with NextPage type)
8282

8383
```tsx
84-
import type { NextPage } from 'next';
84+
import type { NextPage } from "next";
8585
const Page: NextPage = () => {
8686
return <></>;
8787
};
8888
export default Page;
8989
```
90+
91+
4. `nextct` (Next JS Component with NextComponentType and Props)
92+
93+
```tsx
94+
import type { NextComponentType, NextPageContext } from "next";
95+
interface Props {}
96+
const Component: NextComponentType<NextPageContext, {}, Props> = (
97+
props: Props
98+
) => {
99+
return <div></div>;
100+
};
101+
export default Component;
102+
```

snippets/next-typescript.code-snippets

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,22 @@
3838
"export default ${1:${TM_FILENAME}}"
3939
],
4040
"description": "NextPage component with NextPage type"
41-
}
41+
},
42+
"nct": {
43+
"prefix": "nextct",
44+
"body": [
45+
"import type { NextComponentType, NextPageContext } from \"next\";",
46+
"interface Props {}",
47+
"const ${1:${TM_FILENAME_BASE}}: NextComponentType<NextPageContext, {}, Props> = (",
48+
" props: Props,",
49+
") => {",
50+
" return (",
51+
" <div></div>",
52+
" )",
53+
"}",
54+
"",
55+
"export default ${1:${TM_FILENAME_BASE}}"
56+
],
57+
"description": "Next JS Component with NextComponentType and Props"
58+
}
4259
}

0 commit comments

Comments
 (0)