source: imaps-frontend/node_modules/react-use/lib/useHover.js

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: 986 bytes
RevLine 
[d565449]1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var tslib_1 = require("tslib");
4var React = tslib_1.__importStar(require("react"));
5var util_1 = require("./misc/util");
6var useState = React.useState;
7var useHover = function (element) {
8 var _a = useState(false), state = _a[0], setState = _a[1];
9 var onMouseEnter = function (originalOnMouseEnter) { return function (event) {
10 (originalOnMouseEnter || util_1.noop)(event);
11 setState(true);
12 }; };
13 var onMouseLeave = function (originalOnMouseLeave) { return function (event) {
14 (originalOnMouseLeave || util_1.noop)(event);
15 setState(false);
16 }; };
17 if (typeof element === 'function') {
18 element = element(state);
19 }
20 var el = React.cloneElement(element, {
21 onMouseEnter: onMouseEnter(element.props.onMouseEnter),
22 onMouseLeave: onMouseLeave(element.props.onMouseLeave),
23 });
24 return [el, state];
25};
26exports.default = useHover;
Note: See TracBrowser for help on using the repository browser.