#reconcile within produce
4 messages · Page 1 of 1 (latest)
Both return an update function for the store, so in those terms no. What are you trying to accomplish?
Maybe something like:
function upsertUser(user: User) {
const index = untrack(() => state.users.findIndex((u) => u.id === user.id));
if (index === -1) setState('users', (users) => [...users, user]);
else setState('users', index, reconcile(user));
}
@agile juniper Thanks. I just wanted to batch update the store without calling multiple setter functions. In my case it would just be best to call the multiple setters for the nested properties.
… so wrap 'em in batch?