← [ BACK_TO_NOTES ]

TanStack Query 知识地图

TanStack Query 专题知识索引,覆盖 server-state projection、query identity、freshness、Mutation/invalidation、竞态恢复、SSE 集成与工程实践。

#moc #evergreen #frontend #react

TanStack Query 知识地图

知识总览

filters:
  and:
    - 'file.ext == "md"'
    - 'file.inFolder("z")'
    - 'this.file.links.contains(file)'
    - 'file.path != this.file.path'
formulas:
  knowledge: 'file.asLink(title)'
properties:
  formula.knowledge:
    displayName: 知识
  note.description:
    displayName: Description
  note.mastery:
    displayName: Mastery
views:
  - type: table
    name: 知识总览
    order:
      - formula.knowledge
      - note.description
      - note.mastery
    columnSize:
      formula.knowledge: 280
      note.description: 760
      note.mastery: 56

TanStack Query 主要管理的是服务端事实在客户端的 cache/projection 与同步生命周期,而不是新的 durable truth。

最重要的判断:queryKey 表达远程数据身份;stale 表达 freshness;setQueryData / invalidateQueries 的选择取决于客户端掌握了多少 authoritative evidence。


入门


缓存管理


请求控制


高级查询模式


集成模式


实践与迁移


架构上下文


60 秒复习

queryKey   = 远程数据身份/cache address
queryFn    = 如何取得它
QueryCache = server state 的客户端 projection
staleTime  = freshness policy,不是 truth policy
isFetching = 当前正在同步,不等于没有 data

完整 authoritative mutation response
→ setQueryData 可行

不知道完整后果 / 409 stale revision
→ invalidate + refetch

创建于 2026/7/3 更新于 2026/9/10
Digital Biome
Access

键盘导航

j / k / ↑ / ↓
选择对象
Enter / o
打开选择
/ 或 Ctrl+K
全站搜索
i / f / 1–4
筛选当前列表
g → h / l / p / t / a
首页 / 笔记 / 项目 / 工具 / About
r → 1–9
打开所选对象的关联
u
返回上一页
Esc
关闭浮层 / 取消命令;输入框内清空文本