persistentBoolean initial has no sense
When I use `persistentBoolean('test', true)` it works ugly: it removes storage when value `false`. So if I reload the page there is no storage and it uses initial value `true`. Before reload it's `false`, after `true`.
```js
export function persistentBoolean(key, initial = false, opts = {}) {
return persistentAtom(key, initial, {
...opts,
decode(str) {
return str === 'yes'
},
encode(value) {
return initial === value ? undefined : initial ? 'no' : 'yes' // <--- CHANGE THIS
}
})
}
```
9 条评论