Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# 0.1.0 (2022-02-10)
# 0.1.0 (2022-02-11)


### Features

* add nextjs snippet ([8bd2027](https://github.com/avneesh0612/React-Next.js-snippets/commit/8bd2027d3a8fc5d30ea926319f263f029463139d))
* added next js typescript component ([7da5468](https://github.com/avneesh0612/React-Next.js-snippets/commit/7da54689a5ab29ac27d9cf7c5dbf48e3e7f80ed8))



60 changes: 34 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ NextJS and React Snippets with TypeScript support as well!🚀

```jsx
const Component = () => {
return <div></div>;
};
export default Component;
return <div></div>
}
export default Component
```

### TypeScript

2. `rafect` (React Functional Component with Types)

```tsx
import { FC } from "react";
import { FC } from 'react'
interface Props {}
const Component: FC<Props> = () => {
return <div></div>;
};
export default Component;
return <div></div>
}
export default Component
```

## NextJS
Expand All @@ -46,8 +46,8 @@ NextJS and React Snippets with TypeScript support as well!🚀
export const getServerSideProps = async (context) => {
return {
props: {},
};
};
}
}
```

2. `nextssg` (Get Static Props Next.js)
Expand All @@ -56,8 +56,8 @@ NextJS and React Snippets with TypeScript support as well!🚀
export const getStaticProps = async (context) => {
return {
props: {},
};
};
}
}
```

### TypeScript
Expand All @@ -66,37 +66,45 @@ NextJS and React Snippets with TypeScript support as well!🚀

```tsx
export const getServerSideProps: GetServerSideProps = async (context) => {
return { props: {} };
};
return { props: {} }
}
```

2. `nextssgt` (Get Static Props Next.js)

```tsx
export const getStaticProps: getStaticProps = async (context) => {
return { props: {} };
};
return { props: {} }
}
```

3. `taytay` (NextPage component with NextPage type)
3. `nextgip` (Get Initial Props in Next.js)

```tsx
import type { NextPage } from "next";
Page.getInitialProps = async (context) => {
return { props: {} }
}
```

3) `taytay` (NextPage component with NextPage type)

```tsx
import type { NextPage } from 'next'
const Page: NextPage = () => {
return <></>;
};
export default Page;
return <></>
}
export default Page
```

4. `nextct` (Next JS Component with NextComponentType and Props)
4) `nextct` (Next JS Component with NextComponentType and Props)

```tsx
import type { NextComponentType, NextPageContext } from "next";
import type { NextComponentType, NextPageContext } from 'next'
interface Props {}
const Component: NextComponentType<NextPageContext, {}, Props> = (
props: Props
props: Props,
) => {
return <div></div>;
};
export default Component;
return <div></div>
}
export default Component
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@
"devDependencies": {
"husky": "^7.0.4"
}
}
}
16 changes: 14 additions & 2 deletions snippets/next-typescript.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,29 @@
"body": [
"import type { NextPage } from \"next\";",
"",
"const ${1:${TM_FILENAME}}: NextPage = () => {",
"const ${1:${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}}: NextPage = () => {",
" return (",
" <>",
" </>",
" )",
"}",
"",
"export default ${1:${TM_FILENAME}}"
"export default ${1:${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}}"
],
"description": "NextPage component with NextPage type"
},
"nextgip": {
"prefix": "nextgip",
"body": [
"${1:${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}}.getInitialProps = async context => {",
" return {",
" ",
" };",
"};",
""
],
"description": "Get Initial Props in Next.js"
},
"nct": {
"prefix": "nextct",
"body": [
Expand Down
4 changes: 2 additions & 2 deletions snippets/react-javascript.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"rafce": {
"prefix": "rafce",
"body": [
"const ${1:${TM_FILENAME}}= () => {",
"const ${1:${TM_FILENAME_BASE}}= () => {",
" return <div></div>;",
"};",
"",
"export default ${1:${TM_FILENAME}};",
"export default ${1:${TM_FILENAME_BASE}};",
""
],
"description": "React Functional Component"
Expand Down
4 changes: 2 additions & 2 deletions snippets/react-typescript.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"",
"interface Props {}",
"",
"const ${1:${TM_FILENAME}}: FC<Props> = () => {",
"const ${1:${TM_FILENAME_BASE}}: FC<Props> = () => {",
" return <div></div>;",
"};",
"export default ${1:${TM_FILENAME}};"
"export default ${1:${TM_FILENAME_BASE}};"
],
"description": "React Functional Component with Types"
}
Expand Down