Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork17
Commit85479ba
committed
(fix): handle non-existent key in storage
- if key is falsey, i.e. when storage has been cleared or has yet to be set to initial state, applySnapshot will fail and throw an error - so don't apply it if falsey, just skip the applySnapshot call - was thinking of applying `{}`, an empty object, if falsey, but this will reset the initial state of the store to its defaults - one might set initial state in `create({ ... })`, so that alternative doesn't work - getting the initial snapshot and setting it to itself was another alternative considered, but that would be quite complex with unnecessary operations, and might cause some unintended behavior due to whitelists, blacklists, etc applying - still need to think about the ramifications of those since applySnapshot doesn't merge, it just sets (and defaults are applied on top) - see also#11 parent91b8758 commit85479ba
1 file changed
+2
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| |||
0 commit comments
Comments
(0)