본문 바로가기

Web

props

javascript map, foreach등 기본적인 함수 다시 복습 

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map

 

Array.prototype.map()

The map() method creates a new array populated with the results of calling a provided function on every element in the calling array.

developer.mozilla.org

 

immutable => 원본 배열을 유지할 것 = 새로운 배열을 만들 것 

React는 내용이 바뀌어야 렌더링이 되기 때문에 내용이 바뀌었는지 안 바뀌었는지 알아야 한다. 배열은 바구니에 해당되기 때문에 바구니에 어떤 데이터가 담겼는지는 알 수 없고, 새로운 바구니를 만들어서 줘야 자식은 바뀌었다는 것을 알 수 있다. React에서는 immutable 함수(map, filter 등)을 쓰라고 권장하고 있다.

'Web ' 카테고리의 다른 글

function component  (0) 2020.01.11
JSX 문법  (0) 2020.01.11
React Element  (0) 2020.01.11