From cf6fcdbd6eec37230b9bfdc6c3c78ffd18ebe8dc Mon Sep 17 00:00:00 2001 From: Seva Zaikov Date: Mon, 3 Jun 2024 22:28:19 -0700 Subject: [PATCH] fix trackingEffects bug when the first value could not be selected (#37) --- src/hooks/combine-state.ts | 2 +- src/hooks/create-state.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hooks/combine-state.ts b/src/hooks/combine-state.ts index 8e89c2e..a849425 100644 --- a/src/hooks/combine-state.ts +++ b/src/hooks/combine-state.ts @@ -84,7 +84,7 @@ export function combineState(...states) { // it is guaranteed that reading `state.getValue` will // return the updated value const updatedValue = states.map((state) => state.getValue()); - combinedState.setValue(() => updatedValue); + combinedState.setValue(updatedValue); }); }); diff --git a/src/hooks/create-state.ts b/src/hooks/create-state.ts index 207c5cc..1f724f4 100644 --- a/src/hooks/create-state.ts +++ b/src/hooks/create-state.ts @@ -436,6 +436,8 @@ function createState( } cb(newSelectedValue); + // update selected value + trackingEffect.selectedValue = newSelectedValue; }); trackingIterators.forEach((trackingIterator) => {