Created
November 18, 2019 14:56
-
-
Save omrimor/85931891bd5d52db82b62a111e381d80 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 useNetworkStateHelper from './useNetworkStateHelper'; | |
import ErrorComponent from './Error'; | |
import LoadingComponent from './Loading'; | |
import EmptyComponent from './Empty'; | |
function MovieList({ isLoading, hasError, movies }) { | |
const { isBusy, showIfBusy } = useNetworkStateHelper({ | |
loading: isLoading, | |
error: hasError, | |
isEmpty: movies.length === 0, | |
LoadingComponent: LoadingComponent, | |
ErrorComponent: ErrorComponent, | |
EmptyComponent: EmptyComponent, | |
}); | |
if (isBusy) return showIfBusy; | |
return movies.map(movie => <div key={movie.id}>{movie.name}</div>); | |
} | |
export default MovieList; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment