UNPKG

888 BTypeScriptView Raw
1import { Attributes, FunctionComponentElement, ComponentElement, ReactElement, ReactNode, DOMElement } from 'react';
2type GetProps<E extends ReactElement = ReactElement> = E extends FunctionComponentElement<infer P> | ComponentElement<infer P, any> | DOMElement<infer P, any> ? P & {
3 ref?: any;
4} : Record<string, any> & {
5 ref?: any;
6};
7/**
8 * ---
9 * category: utilities/react
10 * ---
11 * Clones a React element without overwriting refs.
12 * @param element The element to clone
13 * @param props Props of the element
14 * @param children
15 */
16declare function safeCloneElement<E extends ReactElement = ReactElement, P extends GetProps<E> = GetProps<E>>(element: {
17 ref?: any;
18} & E, props: {
19 style?: any;
20} & Partial<Attributes> & Partial<P>, ...children: ReactNode[]): E;
21export default safeCloneElement;
22export { safeCloneElement };
23//# sourceMappingURL=safeCloneElement.d.ts.map
\No newline at end of file