Skip to content

Commit 024bc8d

Browse files
suleigoldenwtfsayo
andauthored
fix: resolve type error for children in animated.div component (#2462)
Co-authored-by: Sayo <hi@sayo.wtf>
1 parent d666e48 commit 024bc8d

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

client/src/components/chat.tsx

+18-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from "@/components/ui/chat/chat-bubble";
77
import { ChatInput } from "@/components/ui/chat/chat-input";
88
import { ChatMessageList } from "@/components/ui/chat/chat-message-list";
9-
import { useTransition, animated } from "@react-spring/web";
9+
import { useTransition, animated, AnimatedProps } from "@react-spring/web";
1010
import { Paperclip, Send, X } from "lucide-react";
1111
import { useEffect, useRef, useState } from "react";
1212
import { Content, UUID } from "@elizaos/core";
@@ -23,14 +23,18 @@ import { IAttachment } from "@/types";
2323
import { AudioRecorder } from "./audio-recorder";
2424
import { Badge } from "./ui/badge";
2525

26-
interface ExtraContentFields {
26+
type ExtraContentFields = {
2727
user: string;
2828
createdAt: number;
2929
isLoading?: boolean;
30-
}
30+
};
3131

3232
type ContentWithUser = Content & ExtraContentFields;
3333

34+
type AnimatedDivProps = AnimatedProps<{ style: React.CSSProperties }> & {
35+
children?: React.ReactNode;
36+
};
37+
3438
export default function Page({ agentId }: { agentId: UUID }) {
3539
const { toast } = useToast();
3640
const [selectedFile, setSelectedFile] = useState<File | null>(null);
@@ -67,7 +71,6 @@ export default function Page({ agentId }: { agentId: UUID }) {
6771
}
6872
};
6973

70-
7174
const handleSendMessage = (e: React.FormEvent<HTMLFormElement>) => {
7275
e.preventDefault();
7376
if (!input) return;
@@ -167,17 +170,23 @@ export default function Page({ agentId }: { agentId: UUID }) {
167170
leave: { opacity: 0, transform: "translateY(10px)" },
168171
});
169172

173+
const CustomAnimatedDiv = animated.div as React.FC<AnimatedDivProps>;
174+
170175
return (
171176
<div className="flex flex-col w-full h-[calc(100dvh)] p-4">
172177
<div className="flex-1 overflow-y-auto">
173178
<ChatMessageList ref={messagesContainerRef}>
174179
{transitions((styles, message) => {
175180
const variant = getMessageVariant(message?.user);
176181
return (
177-
// @ts-expect-error
178-
<animated.div
179-
style={styles}
180-
className="flex flex-col gap-2 p-4"
182+
<CustomAnimatedDiv
183+
style={{
184+
...styles,
185+
display: "flex",
186+
flexDirection: "column",
187+
gap: "0.5rem",
188+
padding: "1rem",
189+
}}
181190
>
182191
<ChatBubble
183192
variant={variant}
@@ -266,7 +275,7 @@ export default function Page({ agentId }: { agentId: UUID }) {
266275
</div>
267276
</div>
268277
</ChatBubble>
269-
</animated.div>
278+
</CustomAnimatedDiv>
270279
);
271280
})}
272281
</ChatMessageList>

0 commit comments

Comments
 (0)