Created
May 4, 2016 21:17
-
-
Save corbanbrook/2f5432c4747c1e44abd9d78a0d0e8e38 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
const resolveData = (resolves) => (WrappedComponent) => { | |
return (props) => { | |
const ready = Object.keys(resolves).every((key) => { | |
const resolver = resolves[key] | |
const value = props[key] | |
if (typeof resolver === 'function') { | |
return resolver(value) | |
} else if (resolver === true) { | |
return !isNil(value) | |
} else if (resolver === false) { | |
return value === false | |
} else if (resolver === null) { | |
return value !== undefined | |
} | |
}) | |
if (ready) { | |
return <WrappedComponent {...props}/> | |
} else { | |
return <span/> | |
} | |
} | |
} | |
export default resolveData({ | |
children: true, | |
appStyles: (value) => !isEmpty(value) | |
})(ParallaxHeader) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment