-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Labels
Description
Description
React strict mode causes the useChat to initialize twice and when I try to start conversation in useEffect - eg. based on provided initial message from props, sendMessage calls API twice and apparently this cause very strange side effects like two opened streams. I tried to stop the first stream in useEffect when the component is unmounting but it's not working. Any idea how this should be handled? It's obviously only in development. I temporarily , switch off strict mode, but it's not the option in the long run
AI SDK Version
"@ai-sdk/openai": "2.0.0",
"@ai-sdk/provider": "^2.0.0",
"@ai-sdk/provider-utils": "^3.0.1",
"@ai-sdk/react": "^2.0.1",
"ai": "^5.0.0",
"react": "^19.0.0",
"next": "15.3.5",