ai icon indicating copy to clipboard operation
ai copied to clipboard

Add updater functionality for react setMessage

Open sshkeda opened this issue 1 year ago • 3 comments

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

sshkeda avatar Dec 07 '23 03:12 sshkeda

PR created https://github.com/vercel/ai/pull/832

sshkeda avatar Dec 07 '23 03:12 sshkeda

Any updates on this?

Gr33nLight avatar Feb 16 '24 19:02 Gr33nLight

Bump on this

kachar avatar Mar 15 '24 15:03 kachar

https://github.com/vercel/ai/pull/2347

lgrammel avatar Jul 19 '24 14:07 lgrammel