Skip to content

Instantly share code, notes, and snippets.

View KATT's full-sized avatar
🐱

Alex / KATT KATT

🐱
View GitHub Profile
@martin-fv
martin-fv / PostList.stories.tsx
Last active April 5, 2024 19:41
Storybook mocking and Supertest with tRPC v10
import { Meta } from "@storybook/react/types-6-0";
import { PostList } from "../PostList";
import { getTRPCMock } from "../getTrpcMock";
export default {
title: "Components/PostList",
component: PostList,
} as Meta;
export const PostListPage = () => {
type AnyFunction = (...args: any[]) => any
function useEvent<T extends AnyFunction>(callback?: T) {
const ref = useRef<AnyFunction | undefined>(() => {
throw new Error("Cannot call an event handler while rendering.")
})
// Or useInsertionEffect if it's React 18
useLayoutEffect(() => {
ref.current = callback
})
@tannerlinsley
tannerlinsley / README.md
Last active April 12, 2024 17:04
Replacing Create React App with the Next.js CLI

Replacing Create React App with the Next.js CLI

How dare you make a jab at Create React App!?

Firstly, Create React App is good. But it's a very rigid CLI, primarily designed for projects that require very little to no configuration. This makes it great for beginners and simple projects but unfortunately, this means that it's pretty non-extensible. Despite the involvement from big names and a ton of great devs, it has left me wanting a much better developer experience with a lot more polish when it comes to hot reloading, babel configuration, webpack configuration, etc. It's definitely simple and good, but not amazing.

Now, compare that experience to Next.js which for starters has a much larger team behind it provided by a world-class company (Vercel) who are all financially dedicated to making it the best DX you could imagine to build any React application. Next.js is the 💣-diggity. It has amazing docs, great support, can grow with your requirements into SSR or static site generation, etc.

So why

@tirumaraiselvan
tirumaraiselvan / shim.js
Last active July 31, 2023 17:05
Mount Hasura on Apollo federated gateway
const { ApolloServer } = require("apollo-server");
const gql = require("graphql-tag");
const fetch = require("node-fetch");
const {
introspectionQuery,
buildClientSchema,
printSchema
} = require("graphql");
const typeDefs = gql`
@okunishinishi
okunishinishi / Remove all git tags
Created March 8, 2014 03:12
Delete all git remote tags
#Delete local tags.
git tag -l | xargs git tag -d
#Fetch remote tags.
git fetch
#Delete remote tags.
git tag -l | xargs -n 1 git push --delete origin
#Delete local tasg.
git tag -l | xargs git tag -d