import React, { PropsWithChildren } from 'react'; import TencentCloudChat, { Message } from '@tencentcloud/chat'; interface MessagePluginElementProps { handle?: (event?:React.SyntheticEvent) => void, children: React.ReactNode, isShow?: boolean, relateMessageType?: TencentCloudChat.TYPES[], message?: Message } export const useMessagePluginElement = < T extends MessagePluginElementProps>(props:PropsWithChildren) => { const { children, handle, isShow, relateMessageType, message, } = props; const isNotRelateMessageType = relateMessageType && !relateMessageType.some((item) => (item === message?.type)); if (!isShow || isNotRelateMessageType) { return null; } return (
{children}
); };