How to implement conditional rendering functionality?

泪湿孤枕 提交于 2021-01-29 06:28:50

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!