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:
566 bytes
|
Rev | Line | |
---|
[d565449] | 1 | "use strict";
|
---|
| 2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 3 | var react_1 = require("react");
|
---|
| 4 | var useSetState = function (initialState) {
|
---|
| 5 | if (initialState === void 0) { initialState = {}; }
|
---|
| 6 | var _a = react_1.useState(initialState), state = _a[0], set = _a[1];
|
---|
| 7 | var setState = react_1.useCallback(function (patch) {
|
---|
| 8 | set(function (prevState) {
|
---|
| 9 | return Object.assign({}, prevState, patch instanceof Function ? patch(prevState) : patch);
|
---|
| 10 | });
|
---|
| 11 | }, []);
|
---|
| 12 | return [state, setState];
|
---|
| 13 | };
|
---|
| 14 | exports.default = useSetState;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.