- Optional: React for Two Computers
- JSX Over The Wire
- What Does "use client" Do?
- Optional: Functional HTML
- Optional: How Imports Work in RSC
- Progressive JSON: How React achieves out of order streaming
- Optional: How RSC Serializes Promises
- React
cache()as a tool for async render consistency - Parallel and recursive route rendering: How Next.js's App Router avoids server waterfalls
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 { useCallback, useRef, useTransition } from 'react'; | |
| /** Represents a function with a `setTimeout`-like signature. */ | |
| type SetTimeoutLikeFn<T = unknown> = ( | |
| delayInMs: number, | |
| callbackFn: () => T | Promise<T> | |
| ) => void; | |
| /** | |
| * A utility hook for debouncing synchronous or asynchronous callbacks. |
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
| /** | |
| * A type representing any function. | |
| */ | |
| type AnyFunction = (...args: Array<any>) => any; | |
| /** | |
| * A type representing any generator function. | |
| */ | |
| type GenFn<T = unknown, TReturn = any, TNext = unknown> = ( | |
| ...args: Array<any> |
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
| /** | |
| * @param {EventTarget} target | |
| * @param {string} eventType | |
| * @param {number?} delayInMs | |
| * @returns {Promise<Event>} | |
| */ | |
| function eventTimeout(target, eventType, delayInMs = null) { | |
| const abortController = new AbortController(), | |
| signal = abortController.signal; |
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
| class Bijection<T, U> { | |
| static FORWARD = 0 as const; | |
| static BACKWARD = 1 as const; | |
| #maps = [new Map<T, U>(), new Map<U, T>()] as const; | |
| set(forwardVal: T, backwardVal: U) { | |
| this.#maps[0].set(forwardVal, backwardVal); | |
| this.#maps[1].set(backwardVal, forwardVal); | |
| } |
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
| function transposeGraph(arr: number[][]) { | |
| const graph: Map<number, number[]> = new Map(); | |
| for (let index = 0; index < arr.length; index++) { | |
| if (!graph.has(index)) { | |
| graph.set(index, []); | |
| } | |
| const deps = arr[index]; | |
| for (const dep of deps) { |
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
| type Point = [number, number]; | |
| /** | |
| * Determines the largest area of a rectangle that can be made from a given list of points. | |
| * Rectangles are assumed to be aligned with the axes (no rotations). | |
| * Runtime: O(n^2) | |
| */ | |
| function largestRectArea(points: Point[]): number { | |
| // Map from given x-coordinates to given y-coordinates | |
| const pointsMap: Map<number, Set<number>> = new Map(); |
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
| <!-- Favorite Foods --> | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Favorite Foods</title> | |
| <!-- A link to your CSS stylesheet would go here. --> | |
| <!-- A link to your JavaScript files would go here. --> | |
| </head> | |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>HTML Lesson Page</title> | |
| <!-- A link to your CSS stylesheet would go here. --> | |
| <!-- A link to your JavaScript files would go here. --> | |
| </head> | |
| <body> |