← 返回教程目录
第三章

💻 应用开发

⏱️ 15 分钟中级

1. 创建组件

export default function Home() {
  const [count, setCount] = useState(0)
  return <div><button onClick={() => setCount(count + 1)}>{count}</button></div>
}

2. 使用 TypeScript

interface Props {
  title: string
}

function Card({ title }: Props) {
  return <div>{title}</div>
}

3. 性能优化

const data = useMemo(() => {
  return expensiveComputation()
}, [dependency])