This file contains 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
const Hello = function () { | |
return { | |
render () { | |
return ( | |
<p>Hello, World!</p> | |
); | |
} | |
}; |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Hello</title> | |
</head> | |
<body> | |
<div id="content"></div> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.2/react.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/JSXTransformer.js"></script> |
This file contains 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
const Hello = function (props) { | |
return { | |
props, // set props | |
render () { | |
// get `word` from props obj with | |
// es6 destructuring: |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Hello</title> | |
</head> | |
<body> | |
<div id="content"></div> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.2/react.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/JSXTransformer.js"></script> |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Hello</title> | |
</head> | |
<body> | |
<div id="content"></div> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.2/react.js"></script> | |
<script src="/app-client.js"></script> |
This file contains 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
<p>Hello, | |
<span | |
style = { styles.displayMode } | |
onClick = { () => setMode('edit') } | |
>{ word }!</span> | |
<input | |
ref = "wordInput" | |
style = { styles.editMode } | |
placeholder = { word } | |
onKeyUp = { onKeyUp } /> |
This file contains 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
const styles = { | |
displayMode: { | |
display: (mode === 'display') ? 'inline' : 'none' | |
}, | |
editMode: { | |
display: (mode === 'edit') ? 'inline' : 'none' | |
} | |
}; |
This file contains 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
const onKeyUp = function (e) { | |
if (e.key !== 'Enter') return; | |
setWord(e.target.value); | |
setMode('display'); | |
}; |
This file contains 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
const helloFactory = function ({ React }) { | |
const { | |
string, | |
func | |
} = React.PropTypes; | |
return function Hello (props) { | |
// React wants propTypes | |
// to be static. |
This file contains 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 helloFactory from '../source/hello'; | |
const Hello = helloFactory({ React }); | |
let word = 'world'; | |
let mode = 'display'; | |
let render; | |
const actions = { | |
setWord (w) { |