목록전체 글 (202)
hmk run dev
Grid.js import React from "react"; import styled from "styled-components"; const Grid = (props) => { const { is_flex, width, margin, padding, bg, children } = props; const styles = { is_flex: is_flex, width: width, margin: margin, bg: bg, padding: padding, // 앞은 스타일명 뒤는 props로 받는 padding 값 }; return ( {/* 위에서 props로 넘겨받은 값들은 styles로 오고 styles값은 아래의 스타일컴포넌트 안의 props형태로 정보를 전달해줘 이 컴포넌트 모양이 결정된다 */..
파이어 스토어 데이터를 짤라서 가져와야한다 정렬은 시간 데이터 내림차순! const getPostFB = () => { return function (dispatch, getState, { history }) { const postDB = firestore.collection("post"); let query = postDB.orderBy("insert_dt", "desc").limit(2); //콜랙션에서 내림차순으로 데이터 가져오기 query.get().then((docs) => { let post_list = []; docs.forEach((doc) => { // 잘 가져왔나 확인하기! :) // 앗! DB에서 가져온 것하고 우리가 Post 컴포넌트에서 쓰는 데이터 모양새가 다르네요! // cons..
sum이라는 함수는 a와 b를 인자로 받으며 a + b를 리턴해준다 let sum = (a, b) => a + b; /* 위 화살표 함수는 아래 함수의 축약 버전입니다. let sum = function(a, b) { return a + b; }; */ alert( sum(1, 2) ); // 3 인수가 하나밖에 없다면 인수를 감싸는 괄호를 생략할 수 있습니다. 괄호를 생략하면 코드 길이를 더 줄일 수 있습니다. 예시: let double = n => n * 2; // let double = function(n) { return n * 2 }과 거의 동일합니다. alert( double(3) ); // 6 화살표 함수는 함수 표현식과 같은 방법으로 사용할 수 있습니다. 아래 예시와 같이 함수를 동적으로 ..