mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-15 13:38:29 +02:00

* fix: add ContextIsolator component to Select * feat: add ContextIsolator to mergedPopupRender * feat: useMemo * test: add tests * fix: Delete the 'ContextIsolator' at the top level of the component * feat: add usePopupRender * test: change tests --------- Co-authored-by: 刘欢 <lh01217311@antgroup.com>
18 lines
534 B
TypeScript
18 lines
534 B
TypeScript
import React from 'react';
|
|
|
|
import ContextIsolator from '../_util/ContextIsolator';
|
|
|
|
type RenderFunction<T extends any[]> = (...args: T) => React.ReactNode;
|
|
|
|
function usePopupRender<T extends [React.ReactElement, ...any[]]>(
|
|
renderFn?: RenderFunction<T>,
|
|
): ((...args: T) => React.ReactElement) | undefined {
|
|
return React.useMemo(() => {
|
|
if (!renderFn) {
|
|
return undefined;
|
|
}
|
|
return (...args: T) => <ContextIsolator space>{renderFn(...args)}</ContextIsolator>;
|
|
}, [renderFn]);
|
|
}
|
|
|
|
export default usePopupRender;
|