0.8.0
What's changed
- Add todolist example by @danielart in #40
- Remove confusing reset feature by @aralroca in #44
Breaking changes
-
One this breaking change for this version:
Remove confusing reset feature
#44Reset
function is removed. It's not responsibility of the library. In this way:Pros:
- Removing confusion as to what exactly the reset function did. Simplifying and making it easier to understand.
- Fewer things in memory. Thus it is not necessary to save the store + initialStore. Only the store. This improves performance for applications with very large stores.
- Tiniest. Supporting reset made it take up more bits.
- Removing a feature that did not add value to the library, since the same could be done with the setter.
- More flexibility to the user to reset with the setter where the user wants: last value, last value fetched to an API, initial value...
Cons:
-
The user will be responsible for controlling the reset. That is, save the value in memory.
Example:
const [value, setValue] = useStore.value() const lastValue = useRef(value) // After some changes, is possible to reset with: setValue(lastValue.current)
Another example:
const initialStore = { count: 0 } export const { getStore } = createStore(initialStore) const [,setStore] = getStore() export const reset = () => setStore(initialStore)
import { reset } from './store' function ResetStore() { return <button onClick={reset}>Reset store</button> }
Full Changelog: 0.7.2...0.8.0