반응형 component2 styled-component(1) styled-component 설치 : 해당 프로젝트의 디렉토리에서 실행 npm i styled-components 사용방법 import styled from "styled-components"; const div = styled.div``; // back tick (숫자 1 왼쪽 옆에 있는것)을 입력하고 그 사이에 스타일을 작성한다. const div = styled.div` background-color: red; width: 100px; height: 100px; `; styled-component에 props 전달 const Div = styled.div` background-color: ${(props) => props.bgColor}; width: 100px; height: 100px; `; .. 2022. 7. 11. useEffect ReactJs는 기본적으로 state 가 변경될때 component는 새로 실행됨. (모든 code가 실행됨) 만약 버튼을 누르면 카운트가 증가하고, 키워드를 검색할 수 있는 프로그램이 있다고 가정하면 import {useState, useEffect} from "react"; function App(){ const [counter, setConter] = useState(0); const onClick => () => setCounter((value) => value +1); const [keyword, setKeyword] = useState(""); const onChange = () => setKeyword(event.target.value); return( {counter} click ) } 위.. 2022. 7. 4. 이전 1 다음 반응형