mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
16 lines
397 B
TypeScript
16 lines
397 B
TypeScript
import { cloneElement, isValidElement, type ReactElement } from "react";
|
|
import type { BaseProps, HTMLProps } from "../../shared/types";
|
|
|
|
export const cloneIcon = (
|
|
icon?: ReactElement<HTMLProps<"svg"> & BaseProps>,
|
|
props?: HTMLProps<"svg"> & BaseProps
|
|
) => {
|
|
if (!icon) {
|
|
return null;
|
|
}
|
|
if (!isValidElement(icon)) {
|
|
return null;
|
|
}
|
|
return cloneElement(icon, props ?? {});
|
|
};
|