react-effects
React Effects: When You Do and Don't Need Them
Effects are an escape hatch to synchronize React components with external systems (browser APIs, network, third-party libraries). Most component logic does not need Effects. Before writing or keeping a useEffect, run through the scenarios below — there's likely a simpler, more performant alternative.
The Two Questions
Before every useEffect, ask:
- Is this transforming data for rendering? If yes, compute it during render instead.
- Is this handling a user event? If yes, put it in an event handler instead.
If neither applies, you might actually need an Effect.
Scenarios Where Effects Are Wrong
1. Derived State from Props or State
More from whinc/wechat-miniprogram-skills
miniprogram-automation
Use when working with WeChat mini-program automation (小程序自动化、自动化测试、E2E) via miniprogram-automator, especially for standalone Node scripts or Jest tests involving DevTools launch/connect, page navigation, waitFor, custom-component selectors, wx method mocking, console or exception listeners, screenshots, regression checks, or troubleshooting launch failures, connection timeouts, and element-not-found issues.
154miniprogram-ci
Use when the user wants to automate WeChat mini-program upload, preview, or npm packaging via CI/CD, generate deployment scripts, set up miniprogram-ci workflows, or create preview QR codes automatically. Trigger whenever the user mentions "上传小程序", "预览", "CI 部署", "miniprogram-ci", "自动化上传", "发布小程序版本", "生成预览二维码", "打包npm", "pack-npm", "构建npm依赖", "GitHub Actions 小程序", "pnpm 小程序部署", or asks to integrate WeChat mini-program with continuous integration pipelines (GitHub Actions, GitLab CI, etc.).
132crafting-effective-readmes
Use when writing or improving README files. Not all READMEs are the same — provides templates and guidance matched to your audience and project type.
53commit-work
Create high-quality git commits: review/stage intended changes, split into logical commits, and write clear commit messages (including Conventional Commits). Use when the user asks to commit, craft a commit message, stage changes, or split work into multiple commits.
50