Getting started with react on codepen

Honestly, I suggest using something other than CodePen, such as jsbin.com or codesandbox.io [edit in 2021: I highly suggest codesandbox]. If you really want to use CodePen, you need to add react as a JS dependency. Click on “Settings” at the top of your pen, then “Javascript” in the pop-up. Under “javascript preprocessor”, select Babel, and under “add external scripts/pens”, type “react”. Select both react and react-dom. You should now be ready to use React.

On jsbin, you just need to add the relevant <script> tags, with none of this hoop-jumping.

7 Likes