728x90 반응형 react2 react 라이브러리 styled components css문법 그대로 style을 작성하게 해주는 녀석 https://styled-components.com/ const Button = styled.button` background: transparent; border-radius: 3px; border: 2px solid #BF4F74; color: #BF4F74; margin: 0.5em 1em; padding: 0.25em 1em; ${props => props.$primary && css` background: #BF4F74; color: white; `} `; const Container = styled.div` text-align: center; ` render( Normal Button Primary Button ); 2023. 7. 13. reacthook useCallback 1. useCallback useCallback: useCallback hook은 콜백 함수를 memoize하여 새로운 함수 인스턴스를 생성하는 것을 최적화합니다. 의존성 배열에 기반하여 새로운 콜백 함수 인스턴스를 생성하고, 의존성이 변경되지 않으면 이전에 생성된 콜백 함수 인스턴스를 재사용합니다. 이를 통해 자식 컴포넌트에 전달되는 콜백 함수들이 불필요한 재렌더링을 방지할 수 있습니다. import { useCallback, useState } from 'react'; function Counter() { const [count, setCount] = useState(0); const increment = useCallback(() => { setCount(prevCount => prevCount +.. 2023. 6. 29. 이전 1 다음 728x90 반응형