Skip to content

Commit cc4dcc9

Browse files
committed
no duplicated savedInitValue set
1 parent c67e523 commit cc4dcc9

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed
5 Bytes
Binary file not shown.

examples/server/webui/src/components/ChatScreen.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,14 +297,15 @@ export interface OptimizedTextareaValue {
297297
// This is a workaround to prevent the textarea from re-rendering when the inner content changes
298298
// See https://github.com/ggml-org/llama.cpp/pull/12299
299299
function useOptimizedTextarea(initValue: string): OptimizedTextareaValue {
300-
const [savedInitValue] = useState<string>(initValue);
300+
const [savedInitValue, setSavedInitValue] = useState<string>(initValue);
301301
const textareaRef = useRef<HTMLTextAreaElement>(null);
302302

303303
useEffect(() => {
304-
if (textareaRef.current) {
304+
if (textareaRef.current && savedInitValue) {
305305
textareaRef.current.value = savedInitValue;
306+
setSavedInitValue('');
306307
}
307-
}, [textareaRef, savedInitValue]);
308+
}, [textareaRef, savedInitValue, setSavedInitValue]);
308309

309310
return {
310311
value: () => {

0 commit comments

Comments
 (0)