Instead of checks like:
if (value === null) {
throw new Error("missing value")
}
doSomethingThatNeedsValue(value)
/* eslint-disable @typescript-eslint/no-explicit-any */ | |
import { type TRPCQueryOptions } from '@trpc/tanstack-react-query'; | |
import { unstable_noStore } from 'next/cache'; | |
import { Fragment, Suspense, type ReactNode } from 'react'; | |
import { ErrorBoundary } from 'react-error-boundary'; | |
import { HydrateClient, prefetch as prefetchTRPC } from '@/trpc/server'; | |
type AwaitProps<T> = | |
| { | |
promise: Promise<T>; |
const { safeEnv } = require('./src/env') | |
// Note: NextConfig type allows any keys, so we are plucking the specific keys we want to type-check. | |
/** | |
* @type {Pick< | |
* import('next').NextConfig, | |
* | 'webpack' | |
* | 'env' | |
* >} | |
*/ |
// 粘贴到 chrome devtool console 中执行 | |
// 使用场景 | |
// 1. 想复制只读文档的内容 | |
// 2. 担心复制内容的行为被公司监听了 | |
function removeAllEvents(event) { | |
function removeEvent(el, type) { | |
const listeners = (getEventListeners(el)[type] || []); | |
el[`on${type}`.toLowerCase()] = null; |
import { BroadcastChannel, createLeaderElection } from 'broadcast-channel' | |
import React from 'react' | |
const channels = {} | |
export function useBroadcastLeader(id = 'default') { | |
const [isBroadcastLeader, setIsBroadcastLeader] = React.useState(false) | |
React.useEffect(() => { | |
if (!channels[id]) { |
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.