mirror of
https://github.com/streamich/react-use.git
synced 2026-01-18 14:06:52 +00:00
feat: useMap: allow resetting with provided value other then initial
This commit is contained in:
parent
fc595e8618
commit
7645f7249d
@ -18,7 +18,10 @@ const Demo = () => {
|
||||
Add
|
||||
</button>
|
||||
<button onClick={() => reset()}>
|
||||
Reset
|
||||
Reset to initial
|
||||
</button>
|
||||
<button onClick={() => reset({hello: 'different'})}>
|
||||
Reset with new object
|
||||
</button>
|
||||
<button onClick={() => remove('hello')} disabled={!map.hello}>
|
||||
Remove 'hello'
|
||||
|
||||
@ -27,7 +27,7 @@ const useMap = <T extends object = any>(initialMap: T = {} as T): [T, Actions<T>
|
||||
return rest as T;
|
||||
});
|
||||
},
|
||||
reset: () => set(initialMap),
|
||||
reset: (newMap = initialMap) => set(newMap),
|
||||
}),
|
||||
[set]
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user