Created
February 2, 2024 15:09
-
-
Save samuelint/ce7ab93cb1f009fb090967b92fae82b5 to your computer and use it in GitHub Desktop.
use-hydrate-example--client-side-component.tsx
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
'use client'; | |
import { useHydrate } from 'use-hydrate'; | |
import { setData } from './redux/my.slice'; | |
import { selectData } from './redux/data.selector'; | |
interface Props { | |
existing?: MyData[] | |
} | |
export default function MyClientSideComponent({ existing = [] }: Props) { | |
const data = useHydrate({ initial: existing, action: setData, selector: selectData }); | |
return ( | |
<div className="flex"> | |
{ data } | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment