Skip to content

docs(useeffect): add 'adjust state during render' pattern#25

Open
whinc wants to merge 1 commit intosoftaworks:mainfrom
whinc:main
Open

docs(useeffect): add 'adjust state during render' pattern#25
whinc wants to merge 1 commit intosoftaworks:mainfrom
whinc:main

Conversation

@whinc
Copy link
Copy Markdown

@whinc whinc commented Mar 22, 2026

Resolves #24

Summary

  • Add missing case from React official docs: "Adjusting some state when a prop changes"
  • Add new section "Adjust State During Render (Partial Reset)" with prevItems pattern
  • Update Quick Reference table and Decision Tree to distinguish between reset ALL state vs adjust SOME state

What's Changed

SKILL.md:

  • Added Quick Reference entry for partial state reset scenario
  • Expanded Decision Tree with two branches: "Reset ALL state?" and "Adjust SOME state?"

alternatives.md:

  • Added new Section 4: "Adjust State During Render (Partial Reset)"
  • Includes BAD/BETTER/BEST code examples
  • Documents important constraints and priority order
  • Re-numbered subsequent sections (5-9)
  • Updated Summary table

Why This Matters

The skill previously only covered:

  • key prop (resets ALL state)
  • Store ID and derive object (calculate during render)

This PR adds the middle ground: adjusting state during render when you need to reset some (not all) state when a prop changes, filling the gap between the two existing approaches.

Test plan

  • Verified skill content matches React official documentation
  • Code examples are syntactically correct
  • Section numbering is consistent

Add missing case from React docs "Adjusting some state when a prop changes":
- Add Quick Reference entry for partial state reset scenario
- Add new section in alternatives.md with prevItems pattern
- Update Decision Tree to distinguish reset ALL vs SOME state
- Update Summary table with new pattern

This fills the gap between "key prop" (reset all) and "store ID" (derive) approaches.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

improve react-useeffect

1 participant