Skip to content

Instantly share code, notes, and snippets.

@hackintoshrao
Created September 30, 2021 15:59
Show Gist options
  • Save hackintoshrao/5d7e397ac0ceed16e4408adc79150fab to your computer and use it in GitHub Desktop.
Save hackintoshrao/5d7e397ac0ceed16e4408adc79150fab to your computer and use it in GitHub Desktop.
function Books({ onBookSelected }) {
const { loading, error, data } = useQuery(GET_BOOKS);
if (loading) return 'Loading...';
if (error) return `Error! ${error.message}`;
return (
<select name="book" onChange={onBookSelected}>
{data.books.map(book => (
<option key={book.id} value={book.title}>
{book.title}
</option>
))}
</select>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment