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";
|
---|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
3 | exports.ensuredForwardRef = void 0;
|
---|
4 | var react_1 = require("react");
|
---|
5 | function 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 | }
|
---|
15 | exports.default = useEnsuredForwardedRef;
|
---|
16 | function ensuredForwardRef(Component) {
|
---|
17 | return react_1.forwardRef(function (props, ref) {
|
---|
18 | var ensuredRef = useEnsuredForwardedRef(ref);
|
---|
19 | return Component(props, ensuredRef);
|
---|
20 | });
|
---|
21 | }
|
---|
22 | exports.ensuredForwardRef = ensuredForwardRef;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.