Created
March 27, 2024 13:53
-
-
Save pranitkhadilkar7/2a70daf9919fa05eea2a096e38efa85e to your computer and use it in GitHub Desktop.
src/pages/home/Home.tsx component file to use functional hook exported from RTK Query endpoint
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 { useGetLatestReleaseQuery } from './home-service' | |
export function Home() { | |
const { data, isLoading, isFetching } = useGetLatestReleaseQuery() | |
if (isLoading) return <div>Loading...</div> | |
if (isFetching) return <div>Fetching...</div> | |
if (data) | |
return ( | |
<div className="tw-flex tw-flex-col tw-w-96"> | |
<div className="tw-flex tw-flex-row tw-justify-around"> | |
<div> | |
<p>Month: {data.fspRelease?.month}</p> | |
<p>Year: {data.fspRelease?.year}</p> | |
<p>Type: {data.fspRelease?.type}</p> | |
</div> | |
<div> | |
<p>Month: {data.regRelease?.month}</p> | |
<p>Year: {data.regRelease?.year}</p> | |
<p>Type: {data.regRelease?.type}</p> | |
</div> | |
</div> | |
</div> | |
) | |
return <></> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment