react-use
react-use copied to clipboard
How to get updated object after set() in useMap?
The old store returns
const [store, { set, setAll }] = useMap({
count: 0,
});
set("count", 1);
store.count; // 0 (return not update store)
setAll(newStore => {
newStore.count; // 1 (but the store has already been updated)
...
});
store.count; // 0 (return not update store)
I expect to receive an updated store after using "set()"
A little about versions:
- OS: macOS High Sierra, Windows 10
- Browser (vendor and version): Chrome, Firefox, Safari
- React: 16.12.0
react-use: 15.3.3- Did this worked in the previous package version? I don't know
How's this?
//…
const [store, {get,set, setAll}] = useMap({
count: 0,
});
return (
<p>{get('count')}</p>
);
//…