fix: selected choices not updated reactively on UI

experiment/tanstack-table
Tienson Qin 2024-05-22 06:45:45 +08:00
parent 49d954f3b1
commit a1d4bca586
1 changed files with 5 additions and 0 deletions

View File

@ -52,6 +52,11 @@
{:init (fn [state] {:init (fn [state]
(assoc state ::selected-choices (assoc state ::selected-choices
(atom (set (:selected-choices (first (:rum/args state))))))) (atom (set (:selected-choices (first (:rum/args state)))))))
:will-remount (fn [_old-state new-state]
(let [choices (set (:selected-choices (first (:rum/args new-state))))]
(when (not= choices @(::selected-choices new-state))
(reset! (::selected-choices new-state) choices))
new-state))
:will-unmount (fn [state] :will-unmount (fn [state]
(state/set-state! [:ui/open-select] nil) (state/set-state! [:ui/open-select] nil)
state)} state)}