ant-design/tests/__mocks__/rc-trigger.tsx
2022-12-19 13:31:41 +08:00

13 lines
518 B
TypeScript

import * as React from 'react';
import Trigger from 'rc-trigger/lib/mock';
import type { TriggerProps } from 'rc-trigger';
import { TriggerMockContext } from '../shared/demoTestContext';
const ForwardTrigger = React.forwardRef<any, TriggerProps>((props, ref) => {
const mergedPopupVisible = React.useContext(TriggerMockContext) ?? props.popupVisible;
(global as any).triggerProps = props;
return <Trigger {...props} ref={ref} popupVisible={mergedPopupVisible as boolean} />;
});
export default ForwardTrigger;