From a3cd7f91d5a1591650376b6e91ba34f3c6cd868c Mon Sep 17 00:00:00 2001 From: Arnav Saha <44087308+sahaarnav3@users.noreply.github.com> Date: Fri, 15 May 2026 14:43:44 +0530 Subject: [PATCH] docs: fix duplicate code snippet typo in Zustand selector example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Description Fixes a copy-paste snippet error in the Zustand state selection documentation section of `part6a.md`. ### Context The explanatory text states: *"When instead writing: ... the component no longer reacts to changes in the counter value"*. However, the code block directly beneath it mistakenly duplicated the original unoptimized destructuring snippet (`const { increment, decrement, zero } = useCounterStore()`) from line 359. ### Changes Made Updated lines 365–367 to demonstrate the actual atomic selector pattern intended by the text: ```js const increment = useCounterStore((state) => state.increment) const decrement = useCounterStore((state) => state.decrement) const zero = useCounterStore((state) => state.zero) ``` --- src/content/6/en/part6a.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/content/6/en/part6a.md b/src/content/6/en/part6a.md index 3cedc77e888..404b455de94 100644 --- a/src/content/6/en/part6a.md +++ b/src/content/6/en/part6a.md @@ -363,7 +363,9 @@ The solution works, but it has a significant drawback. Destructuring causes the The best practice in Zustand is therefore to select from the state exactly only those parts that are needed in the given component. A component re-renders only when the part of the state it has selected changes. When instead writing: ```js - const { increment, decrement, zero } = useCounterStore() +const increment = useCounterStore(state => state.increment) +const decrement = useCounterStore(state => state.decrement) +const zero = useCounterStore(state => state.zero)Ï ``` the component no longer reacts to changes in the counter value, because it has not selected it from the state.