source: imaps-frontend/node_modules/react-use/lib/useEnsuredForwardedRef.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: 755 bytes
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.ensuredForwardRef = void 0;
4var react_1 = require("react");
5function useEnsuredForwardedRef(forwardedRef) {
6 var ensuredRef = react_1.useRef(forwardedRef && forwardedRef.current);
7 react_1.useEffect(function () {
8 if (!forwardedRef) {
9 return;
10 }
11 forwardedRef.current = ensuredRef.current;
12 }, [forwardedRef]);
13 return ensuredRef;
14}
15exports.default = useEnsuredForwardedRef;
16function ensuredForwardRef(Component) {
17 return react_1.forwardRef(function (props, ref) {
18 var ensuredRef = useEnsuredForwardedRef(ref);
19 return Component(props, ensuredRef);
20 });
21}
22exports.ensuredForwardRef = ensuredForwardRef;
Note: See TracBrowser for help on using the repository browser.