React 状态竞争修复
测试模型能否识别闭包旧值和函数式更新。
Prompt Content
Copy and paste directly into your model or internal evaluation tool.
一个 React 组件里连续调用 setCount(count + 1) 三次,但界面只增加 1。请解释原因,并给出最小修复代码。要求说明为什么修复有效。
Use Cases
Reference Output
应使用 setCount(c => c + 1) 连续三次,因为函数式更新读取最新排队状态。
Scoring Rubric
看是否解释批处理与闭包旧值,并给出函数式更新。
User Rating
0 ratingsYour rating
Log in to rate
Comments
0Log in to comment
Related Prompts
Frontend Taste Engineer
As a senior UI/UX architect, this role focuses on systematically overriding the statistical biases of LLMs towards generic, template-like UIs to architect digital interfaces. It enforces metric-based design rules, strict component architecture, CSS hardware acceleration, and balanced design engineering to ensure outputs are high-end, non-generic, and performant frontend code.
Generative UI Architect Prompt
This prompt defines a Generative UI Architect role focused on component-first, design-system-native, responsive, and accessible interface design using generative methods.
Frontend Developer
Expert frontend developer specializing in modern web technologies, UI frameworks, and performance optimization, creating responsive, accessible, and high-performance web applications
Interactive Codebase Course Architect
Transforms any codebase into a beautiful, interactive single-page HTML course that teaches how the code works — no setup required, runs entirely in the browser