Thief of Wealth
[React] Prop type `array` is forbidden
개발/Web Programming 2021. 1. 12. 21:09

React 함수 인자를 array로 받기에 PropType을 TodoList.propTypes = { todoList: PropTypes.array.isRequired, }; 으로 설정한다면 Prop type `array` is forbidden 이라는 에러를 접할 것이다. 이 이유는 airbnb eslint에서 금지하고 있기 때문이다. (정확히 말하면 eslint-plugin-react) Why? 왜냐하면 PropTypes.array는 아래 경우가 모두 해당되기 떄문이다. array of objects [{name:'ABC'},{name:'XYZ'}] array of strings ['Lorem','Ipsum'] array of integers [2,4,66,4] array of nested array..

[React] 리액트는 어떻게 화면을 업데이트 하는가?
개발/Web Programming 2021. 1. 10. 20:44

- 비교 알고리즘 (Diffing Algorithm) ko.reactjs.org/docs/reconciliation.html#the-diffing-algorithm 2개의 트리를 비교할 때, 리액트틑 두 Element의 Root 엘리먼트부터 비교한다. 이후의 동작은 root Element의 타입에 따라 달라진다. 1. Element의 타입이 다른 경우 2개의 Root Element 타입이 다르면, 리액트는 이전 트리를 버리고, 완전히 새로운 트리를 구축한다. 트리를 버릴 때에는 이전 DOM 노드들을 모두 파괴되고, 컴포넌트 인스턴스에 componentWillUnmount()가 실행된다. 새로운 트리가 만들어 질 때에는 새로운 DOM노드들이 삽입되고 해당 컴포넌트 인스턴스에 compoenetWillMoun..

profile on loading

Loading...