Skip to content

Instantly share code, notes, and snippets.

@rzkhosroshahi
Created April 26, 2019 17:23
Show Gist options
  • Save rzkhosroshahi/b4874b9b01ce69ff9d36a3779e1899f3 to your computer and use it in GitHub Desktop.
Save rzkhosroshahi/b4874b9b01ce69ff9d36a3779e1899f3 to your computer and use it in GitHub Desktop.
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