Created
November 23, 2019 02:52
-
-
Save moomdate/c529ac84532b41f53e4f6de088c8ea78 to your computer and use it in GitHub Desktop.
Examle vdom in react
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 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