Last active
September 13, 2018 03:52
-
-
Save thulioph/98cffaf64bff4853fec6e86af6fff4df to your computer and use it in GitHub Desktop.
An example to demonstrate the branch API of Recompose
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
import React from 'react'; | |
import { branch } from 'recompose'; | |
const MyComponent = () => <h2>Hello!</h2>; | |
const IsLessThanZero = BaseComponent => props => ( | |
<div> | |
<BaseComponent {...props} /> | |
<h1>Less or equal than zero!</h1> | |
</div> | |
); | |
const IsMoreThanZero = BaseComponent => props => ( | |
<div> | |
<BaseComponent {...props} /> | |
<h1>More than zero!</h1> | |
</div> | |
); | |
const MyComponentModified = branch( | |
(props) => (props.value > 0 ? true : false), | |
IsMoreThanZero, | |
IsLessThanZero | |
)(MyComponent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment