티스토리 뷰
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
import * as React from 'react';
//https://react-etc.vlpt.us/06.typescript-basic.html
interface CounterProps {
startNumber: number;
}
interface CounterState {
number: number;
}
class Counter extends React.Component<CounterProps, CounterState> {
public state = {
number: 0,
}
constructor(props: CounterProps) {
super(props);
this.state.number = props.startNumber;
}
public handleClick = () => {
this.setState({
number: this.state.number + 1,
});
}
public render() {
return (
<div>
<h1>{this.state.number}</h1>
<h1>{this.props.startNumber}</h1>
<button onClick={this.handleClick}>Click Me</button>
</div>
)
}
}
export default Counter;
|
cs |
App.tsx
1 2 3 4 5 6 7 8 9 10 11 | import React from 'react'; import './App.css'; import Counter from './oop/Counter'; class App extends React.Component { public render() { return <Counter startNumber={0} />; } } export default App; | cs |
'3. 스크립트' 카테고리의 다른 글
React index.tsx 설정 ※리덕스-썽크(redux-thunk) (0) | 2020.07.17 |
---|---|
[리액트] Scaling your Redux App with ducks (0) | 2020.07.17 |
TS/VS코드/2020-06-21/ TS tsconfig.json 의 여러 예제 (0) | 2020.06.21 |
[자바스크립트] "자바마저 제쳤다" 자바스크립트, 인기 언어 1위 (0) | 2020.06.18 |
(타슈켄트) 뷰> 중고차플젝 user.js magazine.js (0) | 2020.05.28 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- nodejs
- springMVC
- COLAB
- Eclipse
- mariadb
- KAFKA
- JPA
- ERD
- docker
- jQuery
- AWS
- Mlearn
- database
- tensorflow
- Python
- maven
- SpringBoot
- Algorithm
- Django
- Java
- React
- Oracle
- JUnit
- intellij
- vscode
- Mongo
- FLASK
- terms
- Git
- SQLAlchemy
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
글 보관함