react (2) 썸네일형 리스트형 HOC & Hook & Typscript typescript 를 이용해 hook 으로 hoc 를 만들면서 알게된 내용들을 정리하고자 한다. 수정사항이나 피드백 환영합니당 HOC (Higer Order Component) react 문서에 따르면 고차 컴포넌트는 컴포넌트를 가져와 새 컴포넌트를 반환하는 함수입니다. 라고 한다. 어떤 component 에 기능만 추가해서 새로운 compoennt 를 반환할 때 사용할 수 있다. 자 이제 typescript 와 hook 을 이용해 hoc 함수를 만들어보자. 만들려는 것 props 로 숫자를 받아서 보여주는 다음과 같은 component 가 있다고 해보자. interface ShowNumberProps { value : number } const ShowNumber = ({value} : ShowNum.. useEffect useEffect React Hook 에서 ComponentDidMount 와 ComponentDidupdate 와 같은 기능을 할 수 있게 해주는 api 다. 공식 홈페이지에서는 componentDidMount와 componentDidUpdate, componentWillUnmount가 합쳐진 것으로 생각해도 좋다고 한다. 참고 링크 https://ko.reactjs.org/docs/hooks-faq.html#is-it-safe-to-omit-functions-from-the-list-of-dependencies 사용예 const Test = () => { const [number, setCount] = React.useState(0); React.useEffect(() => { console.log(.. 이전 1 다음