Created
December 7, 2021 16:25
-
-
Save yaralahruthik/388fa2d4d966a12dc515835ae47af143 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useGetTodosQuery } from '../services/todo'; | |
const ReduxWay = () => { | |
const { data, error, isLoading } = useGetTodosQuery(); | |
return ( | |
<div> | |
<h1>Redux Way</h1> | |
{error ? ( | |
<>Oh no, there was an error</> | |
) : isLoading ? ( | |
<>Loading...</> | |
) : data ? ( | |
<> | |
<ul> | |
{data.map((item) => ( | |
<li key={item.id}>{item.title}</li> | |
))} | |
</ul> | |
</> | |
) : null} | |
</div> | |
); | |
}; | |
export default ReduxWay; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment