Skip to content

Instantly share code, notes, and snippets.

@ShMcK
Created July 23, 2018 14:33
Show Gist options
  • Save ShMcK/70585e9b7a8fb70f65451724da416f74 to your computer and use it in GitHub Desktop.
Save ShMcK/70585e9b7a8fb70f65451724da416f74 to your computer and use it in GitHub Desktop.
decouple-state-as-prop
import { withStatechart } from "react-automata"
import alarmMachine from "./alarmMachine"
const AlarmClock = ({ machineState }) => {
switch (machineState.value) {
case "Snoozing":
return <Clock />
case "Ringing":
return <Clock ringing />
default:
return null
}
};
export default withStatechart(alarmMachine)(AlarmClock)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment