From c7504b1038230f2bcefb2340614576b91ed4d177 Mon Sep 17 00:00:00 2001 From: Jing Hua Date: Tue, 7 Mar 2023 13:38:38 +0800 Subject: [PATCH] clear error message on new generation --- src/components/Chat/ChatContent/ChatContent.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/Chat/ChatContent/ChatContent.tsx b/src/components/Chat/ChatContent/ChatContent.tsx index 9b091fc..b8a58ce 100644 --- a/src/components/Chat/ChatContent/ChatContent.tsx +++ b/src/components/Chat/ChatContent/ChatContent.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import ScrollToBottom from 'react-scroll-to-bottom'; import useStore from '@store/store'; @@ -29,6 +29,14 @@ const ChatContent = () => { ? state.chats[state.currentChatIndex].messages.length : 0 ); + const generating = useStore.getState().generating; + + // clear error at the start of generating new messages + useEffect(() => { + if (generating) { + setError(''); + } + }, [generating]); const { handleSubmit, error } = useSubmit();