Open ZongYan30 opened 11 months ago
遇到了,临时处理在组件外加了个变量记录输入的值, const [inputValue, setInputValue] = useState(localInputValue)
@ylinwind 代码是怎么写的呀
const MemoizedCustomComposer = useCallback(
(props: any) => (
<CustomComposer {...props} />
),
[]
)
<Chat
Composer={MemoizedCustomComposer}
messages={messages}
renderMessageContent={renderMessageContent}
onSend={handleSend}
/>
使用useCallback包裹自定义composer,依赖项设置为[]
Version information (版本信息) @2.4.2
Describe the bug (描述问题) BUG: 组件使用composer渲染自定义组件 之后,
每次发送完消息,我自己定义的 就会强制刷新,导致里面刚打印的文本会随着刷新丢失。
Steps To Reproduce (重现步骤) bug:演示:
具体代码实现如下: 1. 的使用,以及自定义composer
2.项目页面
Link to minimal reproduction (最小化重现链接) 有一篇csdn的博客,也有类似的自定义composer重新强制渲染的说明: https://blog.csdn.net/runrun117/article/details/118223631 Expected behavior (期望的结果是什么) 有人可以给出解决建议和思路