CodePen에서 React를 어떻게 쓸까?

HoJeong Im·2021년 7월 5일
0

Problem

  • Codepen에서 React를 사용하고 싶다면 어떻게 해야 할까?

Solution

  1. React, React-dom을 import 받는다.

  • Pen Settings => Add External Scripts/Pens => react, react-dom 검색해서 추가

  • Pen Settings => JavaScript Preprocessor => Babel로 설정

ex) 예시 코드

// index.html
<div id="root"></div>
// index.js
ReactDOM.render(
	<div>test</div>,
  	document.getElementById("root")
)
  • 결과 : 잘 뜨는 것을 확인할 수 있어요!

참고링크

profile
꾸준함이 제일 빠른 길이었다

0개의 댓글