Skip to content

Instantly share code, notes, and snippets.

@fresh5447
Created December 5, 2017 23:04
Show Gist options
  • Save fresh5447/e402c397f981e7bd6b97102e58c6b44b to your computer and use it in GitHub Desktop.
Save fresh5447/e402c397f981e7bd6b97102e58c6b44b to your computer and use it in GitHub Desktop.
declarative-react-decorator-transitions withHandlers and withState
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