import type {CurrentDispatcherRef, LegacyDispatcherRef} from '../types';
export function getDispatcherRef(renderer: {
+currentDispatcherRef?: LegacyDispatcherRef | CurrentDispatcherRef,
...
}): void | CurrentDispatcherRef {
if (renderer.currentDispatcherRef === undefined) {
return undefined;
}
const injectedRef = renderer.currentDispatcherRef;
if (
typeof injectedRef.H === 'undefined' &&
typeof injectedRef.current !== 'undefined'
) {
return {
get H() {
return (injectedRef as any).current;
},
set H(value) {
(injectedRef as any).current = value;
},
};
}
return injectedRef as any;
}