The shadow DOM isn’t ready for real world use cases
In a thread, Bret Little explains why, in his opinion, the shadow DOM is not yet ready for real-world uses.
Published: August 4, 2021 at 12:00 AM
In a thread, Bret Little explains why, in his opinion, the shadow DOM is not yet ready for real-world uses.
Published: August 4, 2021 at 12:00 AM
In React apps that use SSR, where your component code can run both on the server and on the client, it's sometimes important to know where your code is currently running.
In "The Perils of Rehydration", Josh Comeau talks about why the following is a problem for rehydration:
const Component = () => { if (typeof window === 'undefined') { return null } // Client-only code return <>...</>; }
And why waiting until after the Component mounts can help avoid rehydration issues:
const Component = () => { const [hasMounted, setHasMounted] = useState(false); useEffect(() => { setHasMounted(true); }, []); if (!hasMounted) { return null; } // Client-only code return <>...</>; }
Published: August 3, 2021 at 2:50 AM
export const Button = (props: JSX.IntrinsicElements['button']) => { return <button type="button" {...props} />; };
Published: July 31, 2021 at 8:00 PM
These types can be helpful, especially when working with generated types from APIs.
/** * Make all properties in TType required and non-nullable * @example * Definite<{ foo?: string | null }> // => { foo: string } */ export type Definite<TType> = Required<{ [TKey in keyof TType]: NonNullable<TType[TKey]>; }>; /** * Same as Pick, but all picked properties are required and non-nullable * @example * PickDefinite<{ bar?: string | null, foo?: string | null, }, 'bar'> * // => { bar: string } */ export type PickDefinite<TType, TKey extends keyof TType> = Definite< Pick<TType, TKey> >; /** * Retrieve the type of a single property from a type or interface * @example * type BarType = Take<{ foo: string, bar?: string }, 'bar'> * // => string | null | undefined */ export type Take<TType, TKey extends keyof TType> = TType[TKey];
Published: July 30, 2021 at 1:00 AM
always use Hooks at the top level of your React function, before any early returns
Published: July 28, 2021 at 9:30 PM