Created
December 5, 2017 23:04
-
-
Save fresh5447/e402c397f981e7bd6b97102e58c6b44b to your computer and use it in GitHub Desktop.
declarative-react-decorator-transitions withHandlers and withState
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 { compose, withHandlers, withState } from 'recompose'; | |
const App = ({toggleBox, toggleBox2, showingBox, showingBox2}) => | |
<div className="App"> | |
<h1>Declarative Decorator Transitions</h1> | |
<button onClick={toggleBox}>TOGGLE BOX</button> | |
<button onClick={toggleBox2}>TOGGLE BOX 2</button> | |
<Box animationTrigger={showingBox} /> | |
<Box2 animationTrigger={showingBox2} /> | |
</div> | |
const enhance = compose( | |
withState('showingBox', 'toggleBox', true), | |
withState('showingBox2', 'toggleBox2', true), | |
withHandlers({ | |
toggleBox: ({toggleBox}) => toggleBox((toggleBox) => !toggleBox), | |
toggleBox2: ({toggleBox2}) => toggleBox2((toggleBox2) => !toggleBox2) | |
}) | |
); | |
export default enhance(App) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment