import * as React from "react"; import { noop } from "@applicaster/zapp-react-native-utils/functionUtils"; type withAsyncRenderHOCProps = { emitAsyncElementRegistrate?: () => (() => void) | void; emitAsyncElementLayout?: () => void; }; export const withAsyncRenderHOC =
void }>( Component: React.ComponentType
): React.FC & withAsyncRenderHOCProps
) => {
const { emitAsyncElementRegistrate = noop, emitAsyncElementLayout = noop } =
props;
React.useEffect(() => {
if (props.emitAsyncElementRegistrate) {
return emitAsyncElementRegistrate();
}
}, []);
const onAsyncRender = React.useCallback(() => {
if (props.emitAsyncElementLayout) {
emitAsyncElementLayout();
}
}, [emitAsyncElementLayout]);
return (