Created
March 22, 2017 06:27
-
-
Save andreychev/a38f9e9329129d41c6016dcd06b3512d 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, { PropTypes } from 'react'; | |
import Constants from 'cx-api/constants'; | |
import Loading from 'ux/flow/Loading'; | |
function isPending(loadingComponent) { | |
function pendingHOC({ status, loading = {}, children }) { | |
if (status === Constants.STATE_PENDING) { | |
return (<loadingComponent { ...loading } />); | |
} | |
return children || null; | |
} | |
pendingHOC.propTypes = { | |
status: PropTypes.oneOf([ | |
'', | |
Constants.STATE_PENDING, | |
Constants.STATE_RESOLVED, | |
Constants.STATE_REJECTED | |
]), | |
loading: PropTypes.object | |
}; | |
return pendingHOC; | |
} | |
export { isPending }; | |
export default isPending(Loading); |
Author
andreychev
commented
Mar 22, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment