Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- node.js
- 웹뷰
- 도메인
- php
- angular
- fanzeel
- 카카오톡
- Android
- https
- 감사일기
- node
- AWS
- beanstalk
- TypeScript
- nextjs
- Elastic Beanstalk
- NeXT
- 페이스북
- angular4
- react
- 네이티브
- JavaScript
- Route53
- 안드로이드
- 알려줌
- cors
- swift
- hybrid
- S3
- ios
Archives
- Today
- Total
쪼렙 as! 풀스택
React - 16.3 이상에서 DOM 레퍼런스 가져오기. 18.06.08 본문
가끔 오브젝트에 직접 접근해야할 때가 있다.
https://reactjs.org/docs/refs-and-the-dom.html
constructor 에서, React.createRef() 를 해주고.
JSX 에서 ref={this.myFoo} 해주면 된다.
class MyComponent extends React.Component {
constructor(props) {
super(props);
this.myRef = React.createRef();
}
render() {
return <div ref={this.myRef} />;
}
}
사용할 때는, current 로 node 에 접근한다.
const node = this.myRef.current;
'개발 일지 > Web & Server' 카테고리의 다른 글
React, Next, Express, mobX, axios, scss 환경 꾸미기. (1) | 2018.06.11 |
---|---|
18.06.11. React - Next.JS 로 SSR 환경 꾸미기. (0) | 2018.06.11 |
REACT - create-react-app 에서 mobX 사용하기. 18.06.07 (0) | 2018.06.07 |
Angular - 문자열 클립보드에 복사, 영역 선택하기. (0) | 2018.03.13 |
htaccess 에서 CORS 방지하기 위해 Access-Control-Allow-Origin 설정하기. (0) | 2018.02.28 |
Comments