Skip to content

Instantly share code, notes, and snippets.

@moomdate
Created November 23, 2019 02:52
Show Gist options
  • Select an option

  • Save moomdate/c529ac84532b41f53e4f6de088c8ea78 to your computer and use it in GitHub Desktop.

Select an option

Save moomdate/c529ac84532b41f53e4f6de088c8ea78 to your computer and use it in GitHub Desktop.
Examle vdom in react
import React, { Component } from "react";
import "./App.css";
class example extends Component {
constructor(props) {
super(props);
this.state = { data: 0 };
this.run = this.run.bind(this);
}
run() {
this.setState(state => ({
data: (this.state.data += 1)
}));
}
render() {
return (
<div className="App">
<header className="App-header">
<h1>React VDOM</h1>
<div class="row">
<p class="le">number:{this.state.data}</p>
<p class="ri"></p>
</div>
<button class="mbutton" onClick={this.run}>
Hit me
</button>
</header>
</div>
);
}
}
export default example;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment