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.