问题
Using apollo's useQuery, I can implement conditional rendering based on whether my data is loading / it result an error / it is laoded, like this:
function Dogs({ onDogSelected }) {
const { loading, error, data } = useQuery(GET_DOGS);
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>
);
}
How do I implement the same in AWS Amplify?
来源:https://stackoverflow.com/questions/63937866/how-to-implement-conditional-rendering-functionality