Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG:<chat/>组件使用composer渲染自定义组件<inputarea/>之后,每次发送完消息,我自己定义的<inputarea/>就会强制刷新 #128

Open
ZongYan30 opened this issue Nov 3, 2023 · 3 comments

Comments

@ZongYan30
Copy link

Version information (版本信息)
@2.4.2

  • ChatUI or ChatUI Pro?
  • ChatUI
  • ChatUI Version:@2.4.2
  • React Version:v18.2
  • OS Version:win11
  • Browser Version:最新版chrome

Describe the bug (描述问题)
BUG:组件使用composer渲染自定义组件之后,
每次发送完消息,我自己定义的就会强制刷新,导致里面刚打印的文本会随着刷新丢失。

Steps To Reproduce (重现步骤)
bug:演示:
bug

具体代码实现如下:
1.的使用,以及自定义composer
01
02
2.项目页面
03

Link to minimal reproduction (最小化重现链接)
有一篇csdn的博客,也有类似的自定义composer重新强制渲染的说明:
https://blog.csdn.net/runrun117/article/details/118223631
Expected behavior (期望的结果是什么)
有人可以给出解决建议和思路

@ylinwind
Copy link

遇到了,临时处理在组件外加了个变量记录输入的值,
const [inputValue, setInputValue] = useState(localInputValue)

@liyanping111
Copy link

@ylinwind 代码是怎么写的呀

@NOBOUNDer
Copy link

const MemoizedCustomComposer = useCallback(
    (props: any) => (
      <CustomComposer {...props}  />
    ),
    []
  )

 <Chat
        Composer={MemoizedCustomComposer}
        messages={messages}
        renderMessageContent={renderMessageContent}
        onSend={handleSend}
        />

使用useCallback包裹自定义composer,依赖项设置为[]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants