ai
ai copied to clipboard
Add updater functionality for react setMessage
Feature Description
Add updater functionality for react setMessage to make functions like this possible:
function addMessage(message: Message) {
setMessages((messages) => [...messages, message]);
}
Use Case
I am building an extension app to help developers with web accessibility conformance. It is useful to add sequential messages programmatically; however, because there is no updater function, it is hard to sync the message values after each re-render.
See example of me using this feature here https://github.com/sshkeda/waccesible.ai/blob/054c4636840f765e681b0883428b6d57d116c212/extension/src/App.tsx#L29-L84
Additional context
No response
PR created https://github.com/vercel/ai/pull/832
Any updates on this?
Bump on this
https://github.com/vercel/ai/pull/2347