Skip to content

Instantly share code, notes, and snippets.

@willie-hung
Created July 14, 2023 01:56
Show Gist options
  • Save willie-hung/c13b0829e6f12db4ad6c25f2f04cdfdc to your computer and use it in GitHub Desktop.
Save willie-hung/c13b0829e6f12db4ad6c25f2f04cdfdc to your computer and use it in GitHub Desktop.
post_9
import useTodos from "./hooks/useTodos";
const TodoList = () => {
const { data, error, isLoading } = useTodos();
if (isLoading) return <p>Loading...</p>;
if (error) return <p>{error.message}</p>;
return (
<ul className="list-group">
{data?.map((todo) => (
<li key={todo.id} className="list-group-item">
{todo.title}
</li>
))}
</ul>
);
};
export default TodoList;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment