Skip to content

Commit f5271bf

Browse files
authored
Update chat-message-content.tsx trial-debug v5
1 parent d9336bb commit f5271bf

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed
Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
1-
import React, { useEffect, useRef, forwardRef } from "react";
1+
import React, { useEffect, useRef, forwardRef, MutableRefObject } from "react";
22

33
interface ChatMessageContentAreaProps {
44
children?: React.ReactNode;
55
}
66

7-
const ChatMessageContentArea: React.ForwardRefRenderFunction<
8-
HTMLDivElement,
9-
ChatMessageContentAreaProps
10-
> = (props, ref) => {
11-
const internalRef = useRef<HTMLDivElement>(null);
12-
const combinedRef = ref || internalRef;
7+
const ChatMessageContentArea = forwardRef<HTMLDivElement, ChatMessageContentAreaProps>(
8+
(props, ref) => {
9+
const internalRef = useRef<HTMLDivElement>(null);
10+
const combinedRef = (ref as MutableRefObject<HTMLDivElement>) || internalRef;
1311

14-
useEffect(() => {
15-
if (combinedRef && combinedRef.current) {
16-
const links = combinedRef.current.querySelectorAll("a");
17-
links.forEach(link => {
18-
link.setAttribute("target", "_blank");
19-
link.setAttribute("rel", "noopener noreferrer");
20-
});
21-
}
22-
}, [props.children]);
12+
useEffect(() => {
13+
if (combinedRef.current) {
14+
const links = combinedRef.current.querySelectorAll("a");
15+
links.forEach(link => {
16+
link.setAttribute("target", "_blank");
17+
link.setAttribute("rel", "noopener noreferrer");
18+
});
19+
}
20+
}, [props.children]);
2321

24-
return (
22+
return (
2523
<div
26-
ref={combinedRef}
27-
className="container max-w-3xl relative min-h-screen pb-[240px] pt-16 flex flex-col gap-16"
24+
ref={combinedRef}
25+
className="container max-w-3xl relative min-h-screen pb-[240px] pt-16 flex flex-col gap-16"
2826
>
29-
{props.children}
27+
{props.children}
3028
</div>
31-
);
32-
};
29+
);
30+
}
31+
);
3332

34-
export default forwardRef(ChatMessageContentArea);
33+
export default ChatMessageContentArea;

0 commit comments

Comments
 (0)