I don’t believe I ever said this.
I inferred that from this:
Since I am having trouble producing results with Codepen, I am going through another REACT curriculum at Codeacademy.com.
Thus, I thought I might not have my proper scripts/libraries.
OK. So build a starter project in CP.
Start a fresh pen
Let’s start fresh, without any cruff. You can add your JS back in later.
Build a basic HTML pane
<div id="root"></div>
Really, you shouldn’t have to add much, if anything to that.
Add some basic JS
const App = () => <h1>Howdy!</h1>
ReactDOM.render(<App />, document.getElementById('root'))
This will give a basic React app that hooks into that div we created and provides a simple React element.
Add your babel preprocessor
Go to Settings -> JS -> JavaScript Preprocessor and use the pulldown menu to select “Babel”. This will convert the JSX (which is not valid JS) into valid JS. It will happen invisibly behind the scenes. There is no need to worry about this too much, just to understand what it is doing and why it is doing it. You don’t need to know (for now, if ever) about how it is doing it. We could write it out without Babel, but it would be much, much, much uglier and more difficult.
Add your libraries
- Go to
Settings -> JS -> Add External Scrips/Pens. In the “Search CDNJS…”, type “react” Select the entry for “react 18.2.0”. It should enter https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.production.min.js into one of the fields.
This will import the main React library so React will work and you can import extra things if you need them.
- Also in
Settings -> JS -> Add External Scrips/Pens and enter “react-dom” into the search field. Select “react-dom 18.2.0”.
This will import the library you need to hook React into the DOM of your web app.
Those should now be in your libraries. This is different than how you do it in a “real” project, but is make a little more simple for CP. The number “18.2.0” is not super important, as long as they match - the numbers may increase as new versions get added.
- Also in
Settings -> JS -> Add External Scrips/Pens and enter"
https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js
DIRECTLY INTO ONE OF THE LIBRARY FIELDS. You cannot search for the URL because it is not a standard library - we’re just giving it the URL.
This will hook into FCC’s test suite so you can confirm your project.
With that, you should have a basic React project. You should see “Howdy!” on the app and a green hamburger menu that will allow you to access the test suite.
For this project, you should not need any other libraries. Probably, you will just have to add to the CSS pane and the JS pane.