Rendering JSX


#1

import React from ‘react’;
import ReactDOM from ‘react-dom’;

ReactDOM.render(

Hello world

, document.getElementById(‘app’));

What does ‘app’ represent?


#2

its an html element with an id of app, to which we render the result

the element could be anything, its very like a divider (div)


#3

Do we always use ‘app’ or here only we are using ‘app’ because there is a hidden HTML element with id=‘app’?


#4

html elements are never hidden, there might be naming conventions, but i doubt there a strict rules.

if you don’t know html and JS, i would start there, don’t start with reactJS


#5

Actually, I am not able to understand this code

import React from ‘react’;
import ReactDOM from ‘react-dom’;

// Copy code here:
ReactDOM.render(

Hello world

, document.getElementById(‘app’));

When i run this code, it shows Hello World on the output screen and i am not getting why is this happening because there was no html element with id=‘app’


#6

there must be, otherwise nothing would be rendered

html code has to be written within a html file, did you check the html file? It should be there, as should the element with id

if you don’t know html and JS, don’t proceed with this course, learn JS and html first


#7

Got you. I am fimilar with HTML and Js. Actually i am new to Codecademy…Found index.html now…Thanks for the help! :slight_smile: