MCPcopy Create free account
hub / github.com/ballercat/walt / CounterExample

Class CounterExample

packages/webpack-walt-examples/src/CounterExample.js:4–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2import makeCounter from './walt/counter';
3
4export 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected