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 | 29 | 30 | 31 |
Tags
- Android
- typescript
- 타입스크립트
- next Link
- 백준 스택
- 최적화
- react
- javascript
- 백준 스택 시간초과 python
- NPM
- 리액트
- C++
- k for k
- HTML
- CSS
- Python
- kotlin
- 스택
- JS
- 프론트엔드
- 파이어베이스
- firebase
- nodejs
- stdin vs input
- 코딩테스트
- 자바스크립트
- 파이썬
- TS
- 안드로이드
- 알고리즘
Archives
- Today
- Total
sooleeandtomas
REACT 꿀팁 본문
React 꿀팁 1 : 기획서를 보고 미리 컴포넌트 단위로 쪼갠다.
React 꿀팁 2: 코드를 작성하기 전, 들어갈 내용을 미리 간단히 구조를 작성해준다.
<Fragment>
<div>user profile/username/insert_dt/is_me(edit btn)</div>
<div>content</div>
<div>imgae</div>
<div>comment cnt</div>
</Fragment>
React 꿀팁 3: Props가 안넘어 올 경우를 대비해 Default Props를 설정해준다.
Post.defaultProps = {
user_info:{
user_name: "soo",
user_profile: "",
},
image_url: "",
contents: "토슈",
comment_cnt: 10,
insert_dt:"2021-02-27 10:00:00"
};
React 꿀팁 4 : React-developer-Tools 크롬 익스텐션 설치하기
넘겨준 props를 간편하게 console을 찍지 않고도 볼 수 있습니다
Style 꿀팁 1 : Background에 이미지를 넣을 때 가로- 높이 비율 조정하는 법
부모 태그에서 width 값만 지정해줍니다.
const AspectOuter = styled.div`
width: 100%;
min-width: 250px;
`
자식 태그에서
padding으로 높이를 지정해줍니다. 4:3 비율이라면 75% 2:1 비율이라면 50% 로 하면 됩니다.
const AspectInner = styled.div`
position: relative;
padding-top: 75%;
overflow: hidden;
background-image: url(${(props)=> props.src});
background-size: cover;
`
'코딩 공부 노트 > React' 카테고리의 다른 글
Infinity Scroll (Debounce & Throttle 어떤걸 쓰면 좋을까?) (0) | 2021.05.14 |
---|---|
Redux 미들웨어로 saga를 써야 할까? thunk를 써야할까? (0) | 2021.05.14 |
Firebase Storage 사용 : 이미지 저장 (0) | 2021.05.13 |
로그인, 회원가입 관리 (JWT, firebase) (0) | 2021.05.13 |
React Native의 pros & cons (0) | 2021.04.20 |
Comments