Skip to content

Instantly share code, notes, and snippets.

@pranitkhadilkar7
Created March 27, 2024 13:53
Show Gist options
  • Save pranitkhadilkar7/2a70daf9919fa05eea2a096e38efa85e to your computer and use it in GitHub Desktop.
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
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