-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#79) π refactor: μ± μ»΄ν¬λνΈλ νλμ λλ ν 리 μμΌλ‘ μ 리
- Loading branch information
Showing
5 changed files
with
42 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React, { useState, useEffect, useRef } from "react"; | ||
|
||
// μκ° μμλλ‘ μ± μ»΄ν¬λνΈλ₯Ό μΆλ ₯νλ μ»΄ν¬λνΈ | ||
const ChatWithComponents = () => { | ||
const [components, setComponents] = useState<any[]>([]); // μκ°μ λ°λΌ λμΈ μ»΄ν¬λνΈλ€ | ||
const chatContainerRef = useRef<any>(null); // μ±ν 컨ν μ΄λ μ°Έμ‘° | ||
|
||
// μ»΄ν¬λνΈ μΆκ°νλ ν¨μ | ||
const addComponent = (component: JSX.Element) => { | ||
setComponents((prevComponents) => [...prevComponents, component]); | ||
}; | ||
|
||
useEffect(() => { | ||
// μ»΄ν¬λνΈ μΆκ° ν μλ μ€ν¬λ‘€ | ||
if (chatContainerRef.current) { | ||
chatContainerRef.current.scrollTop = chatContainerRef.current.scrollHeight; | ||
} | ||
}, [components]); // μ»΄ν¬λνΈκ° μΆκ°λ λλ§λ€ μ€ν | ||
|
||
return ( | ||
<div | ||
ref={chatContainerRef} | ||
style={{ height: "300px", overflowY: "auto", padding: "10px", border: "1px solid #ccc" }} | ||
> | ||
{/* μκ° μμΌλ‘ μΆκ°λ μ»΄ν¬λνΈ λ λλ§ */} | ||
{components.map((component, index) => ( | ||
<div key={index} style={{ marginBottom: "10px" }}> | ||
{component} | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default ChatWithComponents; |
File renamed without changes.
6 changes: 3 additions & 3 deletions
6
src/pages/Chatbot/components/RookieChat.tsx β ...es/Chatbot/components/chat/RookieChat.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/pages/Chatbot/components/UserChat.tsx β ...ages/Chatbot/components/chat/UserChat.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters