Created
July 20, 2018 03:52
-
-
Save ShMcK/9d219556f8d5ddebb149e4c0b2e8bf89 to your computer and use it in GitHub Desktop.
state-from-actions
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 { withStatechart } from 'react-automata' | |
import alarmMachine from './alarmMachine' | |
class AlarmClock extends React.Component { | |
state = { | |
ringing: false | |
} | |
startRing = () => { | |
this.setState({ ringing: true }) | |
} | |
stopRing = () => { | |
this.setState({ ringing: false }) | |
} | |
render() { | |
return <Clock ringing={this.state.ringing} /> | |
} | |
} | |
export default withStatechart(alarmMachine)(AlarmClock) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment