agentmentoragentmentor

Sources

S1 — React Learn: State as a Component's Memory

URL: https://react.dev/learn/state-a-components-memory

  • 权威: 官方文档
  • 支撑: state 是组件用来记住交互后屏幕状态的记忆。
  • 关键事实: Components often need to remember things such as current input, current image, or cart; React calls this component-specific memory state.

S2 — React Learn: Queueing a Series of State Updates

URL: https://react.dev/learn/queueing-a-series-of-state-updates

  • 权威: 官方文档
  • 支撑: React 会在事件处理函数结束后处理更新队列;函数式 updater 基于上一版 state。
  • 关键事实: React queues updater functions and processes them during the next render.

S3 — React Reference: useState

URL: https://react.dev/reference/react/useState

  • 权威: 官方文档
  • 支撑: useState 返回 state 变量和 setter,用于给组件添加 state。
  • 关键事实: useState is a React Hook that lets you add a state variable to your component.

S4 — Next.js Docs: Server and Client Components

URL: https://nextjs.org/docs/app/getting-started/server-and-client-components

  • 权威: 官方文档
  • 支撑: App Router 中 Server/Client Components 的分工,以及交互 UI 使用 Client Components。
  • 关键事实: Next.js explains when to use Server and Client Components and how to compose them.

S5 — Next.js Docs: use client

URL: https://nextjs.org/docs/app/api-reference/directives/use-client

  • 权威: 官方文档
  • 支撑: "use client" 声明客户端入口,适合 state、事件处理和浏览器 API。
  • 关键事实: The directive declares an entry point for components rendered on the client side and is used for interactive UI requiring client JavaScript capabilities.