This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"arrowParens": "always", | |
"semi": false, | |
"singleQuote": true, | |
"tabWidth": 2, | |
"trailingComma": "none", | |
"plugins": [ | |
"prettier-plugin-tailwindcss" | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.post<{ | |
Body: { | |
userId: string | |
} | |
// More keys: https://fastify.dev/docs/latest/Reference/TypeScript/#using-generics (3rd step) | |
}>( | |
'/my-endpoint', | |
async ({ body }, reply) { | |
console.log(body) // <- is of correct type | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createContext, useContext, useReducer } from 'react' | |
type State = { | |
isLoading: boolean | |
isSignout: boolean | |
userToken: string | null | |
} | |
type Action = | |
| { type: 'LOADED' } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useRouter } from "next/router" | |
import { useEffect, useRef } from "react" | |
export const usePreserveScroll = () => { | |
const router = useRouter() | |
const scrollPositions = useRef<{ [url: string]: number }>({}) | |
const isBack = useRef(false) | |
useEffect(() => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Component: React.FC = () => { | |
return <></> | |
} |