@onehat/ui
Version:
Base UI for OneHat apps
20 lines (17 loc) • 393 B
JavaScript
import { forwardRef } from 'react';
export default function withEvents(WrappedComponent) {
return forwardRef((props, ref) => {
if (props.alreadyHasWithEvents) {
return <WrappedComponent {...props} ref={ref} />;
}
const {
onEvent,
} = props;
return <WrappedComponent
{...props}
alreadyHasWithEvents={true}
ref={ref}
fireEvent={onEvent}
/>;
});
}