Skip to content

Commit

Permalink
Updates example code for Next.js in docs (#857)
Browse files Browse the repository at this point in the history
  • Loading branch information
philnash authored Sep 17, 2024
1 parent 4ca10b3 commit 28ecb65
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions docs/nextjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,21 +127,23 @@ Node.js 20 or later.
import { useState } from 'react';
export default function Home() {
const [menuItem, setMenu] = useState<string>('');
const [menuItem, setMenuItem] = useState<string>('');
async function getMenuItem(formData: FormData) {
const theme = formData.get('theme')?.toString() ?? '';
const suggestion = await callMenuSuggestionFlow(theme);
setMenu(suggestion);
setMenuItem(suggestion);
}
return (
<main>
<form action={getMenuItem}>
<label>
<label htmlFor="theme">
Suggest a menu item for a restaurant with this theme:{' '}
</label>
<input type="text" name="theme" />
<input type="text" name="theme" id="theme" />
<br />
<br />
<button type="submit">Generate</button>
</form>
<br />
Expand Down

0 comments on commit 28ecb65

Please sign in to comment.