Created
September 27, 2022 16:22
-
-
Save shinkathe/e35e5125be01f1499fd522121aaa0489 to your computer and use it in GitHub Desktop.
Sample usage of useclient
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
export const MovieList = ({listId}: {listId: string}) => { | |
const [moviesList, setMoviesList] = useState<Movie[]>(); | |
const { loading: loadingMovies } = useFetch<Movie[], unknown>( | |
request(`api/movies/${listId}`), | |
[listId], | |
{ | |
when: () => listId != undefined, | |
onSuccessEffect: setMoviesList | |
} | |
return <div> | |
{moviesList?.map(movie => ...)} | |
</div> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment