티스토리 뷰

Language/Node.js

react Box component 만들기

KyeongRok Kim 2018. 7. 31. 16:16

react Box component 만들기


1
2
3
4
5
6
7
8
9
10
11
import React from "react";
 
class Box extends React.Component {
  render() {
    return (
      <div>hello</div>
    )
  }
}
 
export default Box
cs


hello가 출력되는 Box 만들기.


import Box from './components/Box'

이렇게 import하고 쓴다.


click event만들기

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import React from "react";
 
class Box extends React.Component {
  constructor(props) {
    super(props)
    this.handleOnClick = this.handleOnClick
  }
  handleOnClick(){
    alert("hello")
  }
  render() {
    return (
      <div>
        <button onClick={()=>this.handleOnClick()}>받기</button>
      </div>
    )
  }
}
 
export default Box
cs

화면




end.



공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
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
글 보관함