Last active
August 14, 2018 18:27
-
-
Save Magellol/595e9ce9daf06a7e41fb822808c67467 to your computer and use it in GitHub Desktop.
Conditionally rendering with ramda
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 ifNotReady = ifElse( | |
either( | |
propEq('status', 'init'), | |
propEq('status', 'pending'), | |
), | |
); | |
render() { | |
<> | |
{ifNotReady( | |
() => <CircularProgress size={30} thickness={3} /> | |
ifElse( | |
({ product }) => typeof product === 'undefined', | |
() => <RedirectToError code={HttpStatus.NotFound} />, | |
({ product }) => <Product product={product} /> | |
), | |
)({ status, product })} | |
</> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment