Skip to content

Commit d271a7a

Browse files
Fix incorrect condition in "Chains of computations" example (#8109)
Fixes #8097 The refactored example in the "Chains of computations" section uses an incorrect condition that changes the game logic from the original. The original Effect-based code advances the round after 4 gold cards: - Increments first (0→1, 1→2, 2→3, 3→4) - Then checks `goldCardCount > 3` (true when count is 4) The refactored code with `goldCardCount <= 3` allows 5 gold cards: - Checks before incrementing - Allows counts 0, 1, 2, 3 to increment (4 values) - Advances on the 5th card (when count is 4) This fix changes the condition to `goldCardCount < 3`: - Allows counts 0, 1, 2 to increment (3 values) - Advances on the 4th card (when count is 3) - Matches the original behavior Verified by tracing execution logic and building the docs site locally. Co-authored-by: PaulyBearCoding <PaulyBearCoding@users.noreply.github.com>
1 parent 6a70889 commit d271a7a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/content/learn/you-might-not-need-an-effect.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ function Game() {
437437
// ✅ Calculate all the next state in the event handler
438438
setCard(nextCard);
439439
if (nextCard.gold) {
440-
if (goldCardCount <= 3) {
440+
if (goldCardCount < 3) {
441441
setGoldCardCount(goldCardCount + 1);
442442
} else {
443443
setGoldCardCount(0);

0 commit comments

Comments
 (0)