Skip to content

setThreadId is changing frequently #2721

Closed
@ravvi-kumar

Description

@ravvi-kumar

Description

setThreadId function in package/react/src/use-assistant.ts : whenever input or messages change, the setThreadId function is changing.

i am using searchParam to get the threadId for my application. whenever the threadId in the searchParam changes, i am setting the threadId of the current chat by using "setThreadId" function from useAssistant() hook.
now by following react-hooks rules, I’ve included setThreadId as a dependency in the useEffect hook. However, this results in the useEffect firing even when the input or messages change, because the setThreadId function is changing frequently.

Code example

useEffect(() => {
  if (currentThreadId) {
    getHistory(currentThreadId).then(data => {
      setHistory(data);
    });
    setThreadId(currentThreadId);
  }
}, [currentThreadId, getHistory, setThreadId]);

here if i not include setThreadId in the dependency, then everything works fine. but actually it is depending on "setThreadId"

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai/uibugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions