| 2 | import makeCounter from './walt/counter'; |
| 3 | |
| 4 | export default class CounterExample extends Component { |
| 5 | state = { counter: 0, instance: null }; |
| 6 | |
| 7 | componentWillMount() { |
| 8 | makeCounter().then(mod => this.setState({ instance: mod.instance })); |
| 9 | } |
| 10 | |
| 11 | render() { |
| 12 | return ( |
| 13 | <div> |
| 14 | <p>Counter: {this.state.counter}</p> |
| 15 | {this.state.instance ? ( |
| 16 | <div> |
| 17 | <button onClick={() => |
| 18 | this.setState({ |
| 19 | counter: this.state.instance.exports.increment() |
| 20 | }) |
| 21 | } >Increment!</button> |
| 22 | <button onClick={() => |
| 23 | this.setState({ |
| 24 | counter: this.state.instance.exports.decrement() |
| 25 | }) |
| 26 | } >Decrement!</button> |
| 27 | </div> |
| 28 | ) : (<span>Loading WebAssembly Module...</span>)} |
| 29 | </div> |
| 30 | ); |
| 31 | } |
| 32 | } |
| 33 |
nothing calls this directly
no outgoing calls
no test coverage detected