main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
485 bytes
|
Line | |
---|
1 | import { useCallback, useState } from 'react';
|
---|
2 | var useSetState = function (initialState) {
|
---|
3 | if (initialState === void 0) { initialState = {}; }
|
---|
4 | var _a = useState(initialState), state = _a[0], set = _a[1];
|
---|
5 | var setState = useCallback(function (patch) {
|
---|
6 | set(function (prevState) {
|
---|
7 | return Object.assign({}, prevState, patch instanceof Function ? patch(prevState) : patch);
|
---|
8 | });
|
---|
9 | }, []);
|
---|
10 | return [state, setState];
|
---|
11 | };
|
---|
12 | export default useSetState;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.