Skip to content

Commit 0b5649d

Browse files
authored
Merge pull request #29 from dottostack/feat/action
fix: react binding with atom
2 parents abf6882 + cb03e4f commit 0b5649d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/react/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ export const useStore = (store, selector) => {
55
let [, force] = useState({})
66
useEffect(() => {
77
let cb = () => unstable_batchedUpdates(() => force({}))
8-
return store._run ? store.listen(cb) : store.watch(selector, cb)
8+
return store._run || !store.watch
9+
? store.listen(cb)
10+
: store.watch(selector, cb)
911
}, [selector, store])
1012
return store.get(selector)
1113
}

packages/validator/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { computed, createAtom, take } from 'dotto.x'
1+
import { computed, createAtom, take, update } from 'dotto.x'
22
import { onChange } from 'dotto.x/lifecycle'
33
import { get } from 'dotto.x/utils/get'
44

@@ -15,7 +15,7 @@ export const validator = (store, rules) => {
1515
if (res) reason = res
1616
return res
1717
})
18-
errors.set({ ...errors.get(), [path]: reason })
18+
update(errors, data => ({ ...data, [path]: reason }))
1919
}
2020
})
2121
return { errors, destroy, valid }

0 commit comments

Comments
 (0)