Im new to codepen and also react i have the following pen in codepen but cant figure out why i am not seeing hello world in the output. I have added react and react dom and i am using the babel preprocceser.
here is a link
Im new to codepen and also react i have the following pen in codepen but cant figure out why i am not seeing hello world in the output. I have added react and react dom and i am using the babel preprocceser.
here is a link
You need to render the component using the root you created. I’d also suggest you put it at the bottom and not the top of the file.
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<MyComponent />);
Alright i got it figured out thanks. Also if you are just writing regular javascript in the code editor how does this get included in the html is writing javascript in the javascript box of the editor like having the code in a different file?
Pretty much like writing it in a file that is automatically linked to for you.
How the js code is added might depend on the setup (plain js vs when using Babel). You can right-click the page and inspect it, then look for the script element with the rendered-js
id.
Ok thanks, i havent tried it yet but figured i would ask. I just went through the Javascript and front end library lessons so i am still new to the client side javascript and still I have some stuff to figure out.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.