Skip to content

Instantly share code, notes, and snippets.

@ShMcK
Created July 20, 2018 03:52
Show Gist options
  • Save ShMcK/9d219556f8d5ddebb149e4c0b2e8bf89 to your computer and use it in GitHub Desktop.
Save ShMcK/9d219556f8d5ddebb149e4c0b2e8bf89 to your computer and use it in GitHub Desktop.
state-from-actions
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