Skip to content

Clarify reducer state updater convention - #8641

Open
rickvian wants to merge 1 commit into
reactjs:mainfrom
rickvian:documentation/reducer-state-updater
Open

Clarify reducer state updater convention#8641
rickvian wants to merge 1 commit into
reactjs:mainfrom
rickvian:documentation/reducer-state-updater

Conversation

@rickvian

@rickvian rickvian commented Sep 5, 2026

Copy link
Copy Markdown

Summary

use prevState from setState argument instead of direct state value

Why

In Past, i actually have production design system component issue caused by someone updates state using existing state directly instead of using prevState from the parameter passed,
i do not want this approach creates bad habit.

The revised lesson teaches new readers the safe convention first: whenever new state is calculated from previous state, pass an updater function and call its argument prevState. It introduces batching only after the implementation is understood, as the reason the convention matters.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

Size changes

Details

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

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.

1 participant