Explain how React hooks work under the hood, specifically focusing on useEffect and useMemo, as if you were explaining them to a junior developer.