Skip to content

Instantly share code, notes, and snippets.

@Magellol
Last active August 14, 2018 18:27
Show Gist options
  • Save Magellol/595e9ce9daf06a7e41fb822808c67467 to your computer and use it in GitHub Desktop.
Save Magellol/595e9ce9daf06a7e41fb822808c67467 to your computer and use it in GitHub Desktop.
Conditionally rendering with ramda
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