source: imaps-frontend/node_modules/react-use/lib/useRafState.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 745 bytes
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var tslib_1 = require("tslib");
4var react_1 = require("react");
5var useUnmount_1 = tslib_1.__importDefault(require("./useUnmount"));
6var useRafState = function (initialState) {
7 var frame = react_1.useRef(0);
8 var _a = react_1.useState(initialState), state = _a[0], setState = _a[1];
9 var setRafState = react_1.useCallback(function (value) {
10 cancelAnimationFrame(frame.current);
11 frame.current = requestAnimationFrame(function () {
12 setState(value);
13 });
14 }, []);
15 useUnmount_1.default(function () {
16 cancelAnimationFrame(frame.current);
17 });
18 return [state, setRafState];
19};
20exports.default = useRafState;
Note: See TracBrowser for help on using the repository browser.