
React에서 $$typeof 심볼은 무엇인가?
개발/FrontEnd Interview
2021. 9. 6. 11:28
React에서 $$typeof 심볼은 무엇인가? react element를 console.log로 찍어보면 $$typeof 라는 심볼이 있는것을 한번쯤은 보았을 것이다. 보통 아래와 같은 객체로 찍힌다. { type: 'div', props: { bgcolor: '#ffa7c4', children: 'hi', }, key: null, ref: null, $$typeof: Symbol.for('react.element'), } jsx로 문법을 작성하게 되면, React에서는 React.createElement(type, props, children) 라는 메서드를 이용하여 변환되게 되는데, 이 React.createElement 함수가 $$typeof 프로퍼티를 추가해준다. 그 이유는 XSS 공격을 막기위..