Created
June 6, 2018 17:30
-
-
Save hellsan631/fe02135a887231469aadf127e53c425d to your computer and use it in GitHub Desktop.
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 { h, Component } from 'preact'; | |
import { observer } from 'mobx-preact'; | |
import box from 'mobx-box'; | |
@observer | |
class LightSwitch extends Component { | |
@box lightsOn = false; | |
render() { | |
return ( | |
<span> | |
Lights {this.lightsOn ? 'On' : 'Off'} | |
</span> | |
); | |
} | |
} | |
export default LightSwitch; |
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 { h, Component } from 'preact'; | |
import { observer } from 'mobx-preact'; | |
import box from 'mobx-box'; | |
@observer | |
class LightSwitch extends Component { | |
@box lightsOn = false; | |
constructor(props) { | |
super(props); | |
if (props.defaultLights) { | |
this.lightsOn = props.defaultLights; | |
} | |
} | |
render() { | |
return ( | |
<span> | |
Lights {this.lightsOn ? 'On' : 'Off'} | |
</span> | |
); | |
} | |
} | |
export default LightSwitch; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment