Skip to content

Instantly share code, notes, and snippets.

@iamdustan
Created May 16, 2015 01:27
Show Gist options
  • Select an option

  • Save iamdustan/469dbfa13dff3d7c0680 to your computer and use it in GitHub Desktop.

Select an option

Save iamdustan/469dbfa13dff3d7c0680 to your computer and use it in GitHub Desktop.
/*eslint no-console:0*/
import React from '../';
const {
Board,
Button,
Led,
} = React;
const HIGH = 255;
const LOW = 0;
class Application extends React.Component {
constructor(props) {
super(props);
this.state = {value: LOW};
this.toggle = this.toggle.bind(this);
}
toggle() {
this.setState({value: this.state.value === LOW ? HIGH : LOW});
}
render(): ?ReactElement {
return (
<Board>
<Button onPress={this.toggle} onRelease={this.toggle} />
<Led pin={9} value={this.state.value} />
</Board>
);
}
}
var PORT = '/dev/tty.usbmodem1411';
React.render(<Application value={HIGH} />, PORT);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment