What is the difference between an element and a component in React?
React에서 Element와 Component의 차이는 무엇입니까?
나의 답변
Element는 React내에서 DOM node를 가리키는데 사용하곤 합니다.
React내에서 Component는 function혹은 class이며, state를 가지고 있습니다.
추가학습
Elements
Elements는 React Application을 구성하는 블럭과 같습니다. Element는 immutable 하며, 우리가 화면에서 보게되는 것을 이야기합니다.
Element는 바로 사용되지는 않으며, Component에서 리턴받아서 사용되곤 합니다.
xconst element = <h1>Hello, World!</h1>;
Components
Component는 props를 받아 Elements를 출력하는 함수와 같습니다.
Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen.
참고
https://reactjs.org/docs/components-and-props.html
https://reactjs.org/docs/glossary.html#elements
https://medium.com/@dan_abramov/react-components-elements-and-instances-90800811f8ca
'FrontEnd > Interviews' 카테고리의 다른 글
| Javascript ==와 ===의 차이 (0) | 2019.11.21 |
|---|---|
| CSS preprocessor 장점 단점 (0) | 2019.11.20 |
| Cache busting (0) | 2019.11.20 |
| BEM (Block Element Modifier) (0) | 2019.11.19 |
| alt 속성 (0) | 2019.11.19 |