Skip to content

Instantly share code, notes, and snippets.

@ShMcK
Created September 23, 2018 22:02
Show Gist options
  • Save ShMcK/82e1478bdbc7b83f86d2849d9a02b49b to your computer and use it in GitHub Desktop.
Save ShMcK/82e1478bdbc7b83f86d2849d9a02b49b to your computer and use it in GitHub Desktop.
Conditionally rendered state components
<Display>
<Time />
<ClockMachine.State
is="AlarmGroup.Ringing"
render={() => <AlarmSetIndicator ringing />}
/>
<ClockMachine.State
is={['AlarmGroup.AlarmSet', 'AlarmGroup.Snoozing']}
render={() => <AlarmSetIndicator />}
/>
<Controls>
<ClockMachine.State
is="Normal"
render={() => (
<Button onClick={this.setAlarm}>
Set Alarm After 3 Seconds
</Button>
)}
/>
<ClockMachine.State
is="AlarmGroup.Ringing"
render={() => (
<Button onClick={this.snooze}>
Snooze For 3 Seconds
</Button>
)}
/>
<ClockMachine.State
is="AlarmGroup"
render={() => (
<Button onClick={this.unsetAlarm}>
Cancel Alarm
</Button>
)}
/>
<ClockMachine.State
is="AlarmGroup.Ringing"
render={() => <Ring />)}
/>
</Controls>
</Display>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment