Getting it into your agent
It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.
git clone --depth 1 https://github.com/holtwood/awesome-cursorrules-zhnpx agentmods add rules/holtwood/awesome-cursorrules-zh/observer-hoc-or-useobserver-hookWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/rules/holtwood/awesome-cursorrules-zh/observer-hoc-or-useobserver-hook)<a href="https://agentmods.dev/rules/holtwood/awesome-cursorrules-zh/observer-hoc-or-useobserver-hook"><img src="https://agentmods.dev/badge/rules/holtwood/awesome-cursorrules-zh/observer-hoc-or-useobserver-hook/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/rules/holtwood/awesome-cursorrules-zh/observer-hoc-or-useobserver-hook"><img src="https://agentmods.dev/badge/rules/holtwood/awesome-cursorrules-zh/observer-hoc-or-useobserver-hook.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00000 | $0.00676 |
| Opus 5 | $0.00000 | $0.00338 |
| Sonnet 5 | $0.00000 | $0.00135 |
| Haiku 4.5 | $0.00000 | $0.00068 |
Grade A, and why
observer-hoc-or-useobserver-hook scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 7d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
What it actually says
- 对响应式组件使用
observerHOC 或useObserverhook:observerHOC(高阶组件):observer是mobx-react-lite库提供的一个高阶组件,用于包裹 React 函数式组件或类组件,使其能够响应 MobX 状态的变化。- 当被包裹组件中使用的任何可观察数据发生变化时,
observer会触发组件的重新渲染。 - 示例:
import React from 'react'; import { observer } from 'mobx-react-lite'; import { useStore } from '../stores'; const UserProfile = observer(() => { const { userStore } = useStore(); return ( <div> <h1>{userStore.name}</h1> <p>Email: {userStore.email}</p> <button onClick={() => userStore.updateName('Jane Doe')}>Update Name</button> </div> ); }); export default UserProfile;
useObserverHook:useObserver是mobx-react-lite提供的另一个选择,它是一个 React Hook,允许你在函数式组件的内部定义一个响应式渲染块。- 它适用于需要更细粒度控制渲染,或者只希望组件的某个部分响应 MobX 状态变化的场景。
- 示例:
import React from 'react'; import { useObserver } from 'mobx-react-lite'; import { useStore } from '../stores'; const ProductDisplay = ({ productId }) => { const { productStore } = useStore(); return useObserver(() => { const product = productStore.getProductById(productId); if (!product) return <div>Loading...</div>; return ( <div> <h2>{product.name}</h2> <p>Price: ${product.price}</p> <p>Stock: {product.stock}</p> </div> ); }); }; export default ProductDisplay;
- 选择建议:
- 优先使用
observerHOC:对于大多数情况,直接使用observerHOC 包裹整个函数式组件是更简洁和推荐的做法。它会自动处理组件内部所有可观察数据的响应式更新。 - 在特定场景使用
useObserverHook:当你需要在一个组件中,只有部分 UI 响应 MobX 状态变化,或者需要将响应式逻辑封装在自定义 Hook 中时,useObserver提供了更大的灵活性。 - 性能:两者在性能上都非常高效,因为
mobx-react-lite实现了精确的响应式更新,只在实际观察到的数据发生变化时才触发渲染。
- 优先使用
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 7d ago First seen · 61 lines · 0 tokens per session scan A 34d140f3fca3
observer-hoc-or-useobserver-hook is a cursor rule published in the GitHub repository holtwood/awesome-cursorrules-zh (233 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 676 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.
Other cursor rules, from other repositories
component-development
Modern React + TypeScript component patterns — hooks, typed props, performance optimization, forms, and testing.
app-router-patterns
Next.js 14+ App Router patterns — Server Components, Client Components, Route Handlers, Server Actions, and metadata API.
semiotic-react-dataviz-cursorrules-prompt-file
Cursor rules for Semiotic data visualization library with 30+ chart types, MCP server, and AI-assisted chart generation.
ai-agent-specialist
Cursor rules for TypeScript, React, Node.js, clean architecture, testing, and WHY-oriented engineering guidance.
next-type-llm
Cursor rules for Next.js development with Type LLM integration.
nextjs
Next.js with TypeScript and Tailwind UI best practices.