Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
28 lines
662 B
Plaintext
28 lines
662 B
Plaintext
import React from 'react';
|
|
|
|
// basically Exclude<React.ClassAttributes<T>["ref"], string>
|
|
|
|
var updateRef = function updateRef(ref, value) {
|
|
if (typeof ref === 'function') {
|
|
ref(value);
|
|
return;
|
|
}
|
|
ref.current = value;
|
|
};
|
|
var useComposedRef = function useComposedRef(libRef, userRef) {
|
|
var prevUserRef = React.useRef();
|
|
return React.useCallback(function (instance) {
|
|
libRef.current = instance;
|
|
if (prevUserRef.current) {
|
|
updateRef(prevUserRef.current, null);
|
|
}
|
|
prevUserRef.current = userRef;
|
|
if (!userRef) {
|
|
return;
|
|
}
|
|
updateRef(userRef, instance);
|
|
}, [userRef]);
|
|
};
|
|
|
|
export { useComposedRef as default };
|