Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix (docs): corrected setMessages in Update UI #3151

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions content/docs/02-getting-started/02-nextjs-app-router.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,10 @@ export default function Chat() {
<form
onSubmit={async e => {
e.preventDefault();
const newMessages: CoreMessage[] = [
setMessages(messages => [
...messages,
{ content: input, role: 'user' },
];

setMessages(newMessages);
]);
setInput('');

const result = await continueConversation(newMessages);
Expand Down Expand Up @@ -401,7 +399,7 @@ The only change that you make here is to declare a new value (`data`) and return

Update your root page with the following code:

```tsx filename="app/page.tsx" highlight="14, 17, 37, 39"
```tsx filename="app/page.tsx" highlight="14, 17, 35, 37"
'use client';

import { type CoreMessage } from 'ai';
Expand Down Expand Up @@ -429,12 +427,10 @@ export default function Chat() {
<form
onSubmit={async e => {
e.preventDefault();
const newMessages: CoreMessage[] = [
setMessages(messages => [
...messages,
{ content: input, role: 'user' },
];

setMessages(newMessages);
]);
setInput('');

const result = await continueConversation(newMessages);
Expand Down
Loading