Created
April 26, 2019 17:23
-
-
Save rzkhosroshahi/b4874b9b01ce69ff9d36a3779e1899f3 to your computer and use it in GitHub Desktop.
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 React from 'react'; | |
import PropTypes from 'prop-types'; | |
function WithLoading(Component) { | |
function WihLoadingComponent({ isLoading, error, ...props }) { | |
if (!isLoading && !error) return <Component {...props} />; | |
return <p>there is a problem in fetching url</p>; | |
} | |
WihLoadingComponent.propTypes = { | |
isLoading: PropTypes.bool.isRequired, | |
error: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]).isRequired, | |
}; | |
return WihLoadingComponent; | |
} | |
export default WithLoading; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment