<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>React!</title>
<!-- 리액트 라이브러리와 리액트가 DOM에 대한 작업할 때 필요한 다양한 기능을 추가 -->
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<!-- 바벨, 자바스크립트 컴파일러의 참조 -->
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
<style>
#container {
padding: 50px;
background-color: #EEE;
}
</style>
</head>
<body>
<div id="container"></div>
<script type="text/babel">
var destination = document.querySelector("#container");
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>React!</title>
<!-- 리액트 라이브러리와 리액트가 DOM에 대한 작업할 때 필요한 다양한 기능을 추가 -->
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<!-- 바벨, 자바스크립트 컴파일러의 참조 -->
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
<style>
#container {
padding: 50px;
background-color: #EEE;
}
</style>
</head>
<body>
<div id="container"></div>
<script type="text/babel">
class Counter extends React.Component {
render() {
var textStyle = {
fontSize : 78,
fontFmail : 'sans-serif',
color : '#333',
fontWeight : 'bold'
};
return(
<div style={textStyle}>
{this.props.display}
</div>
)
}
}
class CounterParent extends React.Component {
constructor(props) {
super(props);
this.state = {
count : 0
};
}
render() {
var backgroundStyle = {
padding : 50,
backgroundColor : '#FFC53A',
width : 250,
height : 100,
borderRadius : 10,
textAlign : 'center'
};
var buttonStyle = {
fontSize : '1em',
width : 30,
height : 30,
fontFmail : 'sans-serif',
color : '#333',
fontWeight : 'bold',
lineHeight : '3px'
};
return (
<div style={backgroundStyle}>
<Counter display={this.state.count} />
<button style={buttonStyle}>+</button>
</div>
);
}
}
ReactDOM.render(
<div>
<CounterParent/>
</div>,
document.querySelector("#container")
)
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>React!</title>
<!-- 리액트 라이브러리와 리액트가 DOM에 대한 작업할 때 필요한 다양한 기능을 추가 -->
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<!-- 바벨, 자바스크립트 컴파일러의 참조 -->
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
<style>
#container {
padding: 50px;
background-color: #EEE;
}
</style>
</head>
<body>
<div id="container"></div>
<script type="text/babel">
class Counter extends React.Component {
render() {
var textStyle = {
fontSize : 78,
fontFmail : 'sans-serif',
color : '#333',
fontWeight : 'bold'
};
return(
<div style={textStyle}>
{this.props.display}
</div>
)
}
}
class CounterParent extends React.Component {
constructor(props) {
super(props);
this.state = {
count : 0
};
this.increas = this.increas.bind(this);
}
increas(e) {
this.setState({
count : this.state.count + 1
})
}
render() {
var backgroundStyle = {
padding : 50,
backgroundColor : '#FFC53A',
width : 250,
height : 100,
borderRadius : 10,
textAlign : 'center'
};
var buttonStyle = {
fontSize : '1em',
width : 30,
height : 30,
fontFmail : 'sans-serif',
color : '#333',
fontWeight : 'bold',
lineHeight : '3px'
};
return (
<div style={backgroundStyle}>
<Counter display={this.state.count} />
<button onClick={this.increas} style={buttonStyle}>+</button>
</div>
);
}
}
ReactDOM.render(
<div>
<CounterParent/>
</div>,
document.querySelector("#container")
)
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>React!</title>
<!-- 리액트 라이브러리와 리액트가 DOM에 대한 작업할 때 필요한 다양한 기능을 추가 -->
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<!-- 바벨, 자바스크립트 컴파일러의 참조 -->
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
<style>
#container {
padding: 50px;
background-color: #EEE;
}
</style>
</head>
<body>
<div id="container"></div>
<script type="text/babel">
class Counter extends React.Component {
render() {
var textStyle = {
fontSize : 78,
fontFmail : 'sans-serif',
color : '#333',
fontWeight : 'bold'
};
return(
<div style={textStyle}>
{this.props.display}
</div>
)
}
}
class CounterParent extends React.Component {
constructor(props) {
super(props);
this.state = {
count : 0
};
this.increas = this.increas.bind(this);
}
increas(e) {
var currentCount = this.state.count;
currentCount = (e.shiftKey)? currentCount+=10 : currentCount+=1;
this.setState({
count : currentCount
})
}
render() {
var backgroundStyle = {
padding : 50,
backgroundColor : '#FFC53A',
width : 250,
height : 100,
borderRadius : 10,
textAlign : 'center'
};
var buttonStyle = {
fontSize : '1em',
width : 30,
height : 30,
fontFmail : 'sans-serif',
color : '#333',
fontWeight : 'bold',
lineHeight : '3px'
};
return (
<div style={backgroundStyle}>
<Counter display={this.state.count} />
<button onClick={this.increas} style={buttonStyle}>+</button>
</div>
);
}
}
ReactDOM.render(
<div>
<CounterParent/>
</div>,
document.querySelector("#container")
)
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>React!</title>
<!-- 리액트 라이브러리와 리액트가 DOM에 대한 작업할 때 필요한 다양한 기능을 추가 -->
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<!-- 바벨, 자바스크립트 컴파일러의 참조 -->
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
<style>
#container {
padding: 50px;
background-color: #EEE;
}
</style>
</head>
<body>
<div id="container"></div>
<script type="text/babel">
class Counter extends React.Component {
render() {
var textStyle = {
fontSize : 78,
fontFmail : 'sans-serif',
color : '#333',
fontWeight : 'bold'
};
return(
<div style={textStyle}>
{this.props.display}
</div>
)
}
}
class PlusButton extends React.Component {
render () {
var buttonStyle = {
fontSize : '1em',
width : 30,
height : 30,
fontFmail : 'sans-serif',
color : '#333',
fontWeight : 'bold',
lineHeight : '3px'
};
return(
<button style={buttonStyle}> + </button>
)
}
}
class CounterParent extends React.Component {
constructor(props) {
super(props);
this.state = {
count : 0
};
this.increas = this.increas.bind(this);
}
increas(e) {
var currentCount = this.state.count;
currentCount = (e.shiftKey)? currentCount+=10 : currentCount+=1;
this.setState({
count : currentCount
})
}
render() {
var backgroundStyle = {
padding : 50,
backgroundColor : '#FFC53A',
width : 250,
height : 100,
borderRadius : 10,
textAlign : 'center'
};
return (
<div style={backgroundStyle}>
<Counter display={this.state.count} />
<PlusButton onClick={this.increas}/>
</div>
);
}
}
ReactDOM.render(
<div>
<CounterParent/>
</div>,
document.querySelector("#container")
)
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>React!</title>
<!-- 리액트 라이브러리와 리액트가 DOM에 대한 작업할 때 필요한 다양한 기능을 추가 -->
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<!-- 바벨, 자바스크립트 컴파일러의 참조 -->
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
<style>
#container {
padding: 50px;
background-color: #EEE;
}
</style>
</head>
<body>
<div id="container"></div>
<script type="text/babel">
class Counter extends React.Component {
render() {
var textStyle = {
fontSize : 78,
fontFmail : 'sans-serif',
color : '#333',
fontWeight : 'bold'
};
return(
<div style={textStyle}>
{this.props.display}
</div>
)
}
}
class PlusButton extends React.Component {
render () {
var buttonStyle = {
fontSize : '1em',
width : 30,
height : 30,
fontFmail : 'sans-serif',
color : '#333',
fontWeight : 'bold',
lineHeight : '3px'
};
return(
<button onClick={this.props.clickHandler} style={buttonStyle}> + </button>
)
}
}
class CounterParent extends React.Component {
constructor(props) {
super(props);
this.state = {
count : 0
};
this.increas = this.increas.bind(this);
}
increas(e) {
var currentCount = this.state.count;
currentCount = (e.shiftKey)? currentCount+=10 : currentCount+=1;
this.setState({
count : currentCount
})
}
render() {
var backgroundStyle = {
padding : 50,
backgroundColor : '#FFC53A',
width : 250,
height : 100,
borderRadius : 10,
textAlign : 'center'
};
return (
<div style={backgroundStyle}>
<Counter display={this.state.count} />
<PlusButton clickHandler={this.increas}/>
</div>
);
}
}
ReactDOM.render(
<div>
<CounterParent/>
</div>,
document.querySelector("#container")
)
</script>
</body>
</html>
function doSomething(e) {
console.log(this); // button element
}
var btn = document.querySelector("button");
btn.addEventListener('click', doSomething, false);
this.increas = this.increas.bind(this);