CodePen Preview not Showing Anything

I’m currently working on the Random Quote Generator project from freeCodeCamp and I’ve noticed that the preview isn’t working and I can’t seem to pass any tests. I imported the React and ReactDOM, but I’m not sure what else could be making this happening. Any idea on why?

Here is a link to my project: https://codepen.io/astillround7hief/pen/jOaMpya

i think the test script has to be first. when i swapped it to the first thing, it went to 3/12 passing.
*EDIT: so i went back and tested before making changes and it’s at 3/12 anyways. sorry, i misunderstood what you were asking.

Yeah, the preview window doesn’t display any preview of what I’m working on, and now I see “Uncaught ReferenceError: ReactDom is not defined”.

It is ReactDOM not ReactDom (DOM).

Edit: getRandomIndex is a function you need to call it ().

React.useState(quoteData[getRandomIndex()])

Thanks, this fixed my “Not Defined” error, but my preview window still won’t show anything.

Edit: After a refresh, the preview window is now showing content. Thanks!

1 Like

No problem, happy to help.

Just as an aside, I would suggest checking out CodeSandbox for React code. It also gives you an experience closer to a local development environment. And yes, you can submit projects created with CodeSandbox just as you can with Codepen.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.