ChatUI icon indicating copy to clipboard operation
ChatUI copied to clipboard

setTyping is not a function

Open jinsihou19 opened this issue 8 months ago • 1 comments

Version information (版本信息)

  • ChatUI
  • ChatUI Version: 3.0.0
  • React Version: none
  • OS Version: -
  • Browser Version: -

Describe the bug (描述问题) setTyping is not a function TypeError: setTyping is not a function

Steps To Reproduce (重现步骤)

import React from "react";
import Chat, { Bubble, useMessages } from "@chatui/core";
import "@chatui/core/dist/index.css";

export default function App() {
  const { messages, appendMsg,setTyping } = useMessages([]);

  function handleSend(type, val) {
    if (type === "text" && val.trim()) {
      appendMsg({
        type: "text",
        content: { text: val },
        position: "right",
      });

      setTyping(true);

      // 模拟收到消息
      setTimeout(() => {
        appendMsg({
          type: "text",
          content: { text: "Bala bala" },
        });
      }, 1000);
    }
  }

  function renderMessageContent(msg) {
    const { type, content } = msg;

    // 根据消息类型来渲染
    switch (type) {
      case "text":
        return <Bubble content={content.text} />;
      default:
        return null;
    }
  }

  return (
    <Chat
      navbar={{ title: "智能助理" }}
      messages={messages}
      renderMessageContent={renderMessageContent}
      onSend={handleSend}
    />
  );
}

https://codesandbox.io/p/devbox/chatui-demo-forked-qssjtc

Link to minimal reproduction (最小化重现链接)

Expected behavior (期望的结果是什么)

jinsihou19 avatar Jun 04 '25 06:06 jinsihou19

A workarond is to downgrade to 1.3.0 Version

Harrilee avatar Jun 12 '25 09:06 Harrilee