Last active
November 12, 2018 06:34
-
-
Save NSLog0/4b17249f0041974f02443959eb86daa7 to your computer and use it in GitHub Desktop.
Hooks API
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 from "react"; | |
import ReactDOM from "react-dom"; | |
class Hello extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
text: 'Hello, World!' | |
}; | |
} | |
} | |
// OR | |
class Hello extends React.Component { | |
this.state = { | |
text: 'Hello, World!' | |
}; | |
} | |
const root = document.getElementById("root"); | |
ReactDOM.render(<Hello />, root); |
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, { useState } from "react"; | |
import ReactDOM from "react-dom"; | |
function Hello() { | |
const [text, setText] = useState('Hello, World!'); | |
return ( | |
<div>{text}</div> | |
); | |
} | |
const root = document.getElementById("root"); | |
ReactDOM.render(<Hello />, root); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment