Skip to content

Commit 338c11a

Browse files
committed
Extract status for the easier readability in simple example - docs
1 parent 8a6ec24 commit 338c11a

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -355,21 +355,21 @@ The query `info` returned contains all information about the query and can be ea
355355
function Todos() {
356356
const { status, data, error } = useQuery('todos', fetchTodoList)
357357

358+
if (status === 'loading') {
359+
return <span>Loading...</span>
360+
}
361+
362+
if (status === 'error') {
363+
return <span>Error: {error.message}</span>
364+
}
365+
366+
// also status === 'success', but "else" logic works, too
358367
return (
359-
<div>
360-
{status === 'loading' ? (
361-
<span>Loading...</span>
362-
) : status === 'error' ? (
363-
<span>Error: {error.message}</span>
364-
) : (
365-
// also status === 'success', but "else" logic works, too
366-
<ul>
367-
{data.map(todo => (
368-
<li key={todo.id}>{todo.title}</li>
369-
))}
370-
</ul>
371-
)}
372-
</div>
368+
<ul>
369+
{data.map(todo => (
370+
<li key={todo.id}>{todo.title}</li>
371+
))}
372+
</ul>
373373
)
374374
}
375375
```

0 commit comments

Comments
 (0)