Whenever you're ready, walk me through how you'd approach this.
Explain how React hooks work under the hood, specifically focusing on useEffect and useMemo, as if you were explaining them to a junior developer.
Describe how React associates hook state with a component, why hooks must be called in a stable order, when useEffect callbacks and cleanup functions run, and how dependency arrays affect both hooks. Compare the purpose and guarantees of useEffect and useMemo, including when each is appropriate.
Scope: modern React function components and the React render and commit lifecycle.