Comment

Comment by typon

Consider this code snippet using Apollo React Client:

    const Dogs = ({ onDogSelected }) => (
      <Query query={GET_DOGS}>
        {({ loading, error, data }) => {
          if (loading) return 'Loading...';
          if (error) return `Error! ${error.message}`;

          return (
            <select name="dog" onChange={onDogSelected}>
              {data.dogs.map(dog => (
                <option key={dog.id} value={dog.breed}>
                  {dog.breed}
                </option>
              ))}
            </select>
          );
        }}
      </Query>
    );
parent typon 7 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton