- Compound Components
- Controlled vs Uncontrolled Components
- Headless Components (Logic Hooks + UI Primitives)
- Context + Hooks API Pattern
- Slot / As-Child Pattern
- Config Objects / Options API
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 FormState = { | |
| name: string; | |
| }; | |
| function Form(props: Props) { | |
| async function action(_: FormState, formData: FormData): Promise<FormState> { | |
| const name = formData.get("name") as string; | |
| const surname = formData.get("surname") as string; | |
| console.log({ name, surname }); |
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 DequeNode<T = any> { | |
| value: T; | |
| prev: DequeNode<T> | null; | |
| next: DequeNode<T> | null; | |
| constructor(value: T, prev: DequeNode<T> | null = null, next: DequeNode<T> | null = null) { | |
| this.value = value; | |
| this.prev = prev; | |
| this.next = next; | |
| } |
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 accumulateRecursive(numbers: number[], accumulator: number = 0) { | |
| if (numbers.length === 0) { | |
| return accumulator; | |
| } | |
| const lastIndex = numbers.length - 1; | |
| return accumulateRecursive(numbers.slice(0, lastIndex), accumulator += numbers[lastIndex]) | |
| } | |
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 express from "express"; | |
| import path from "path"; | |
| import { fileURLToPath } from "url"; | |
| import { dirname } from "path"; | |
| const PORT = 8080; | |
| const STATIC_DIR_PATH = "dist"; | |
| const __filename = fileURLToPath(import.meta.url); | |
| const __dirname = dirname(__filename); |