Introduction Flashcards
What is React?
React is a JavaScript Library.
What are JSX elements treated as?
JSX is a syntax extension for JavaScript
You can nest JSX elements inside of other JSX elements, just like in HTML. However, if a JSX expression takes up more than one line, what do you need to add? (Give Example)
You need to add parenthesis around the code, like so:
Const myDiv = ( <div> <h1>Hello world</h1> </div> );
What is one one key thing that a JSX expression must have, what is this?
A JSX expression must always have at least one outermost element, this would look like so:
const paragraph = ( <div> <h1>Hello Seb!</h1> </div> );
How would you render a JSX expression? (Make it appear on screen)
ReactDOM.render(
<h1>Color</h1>
,
document.getElementById(‘app’)
);
Can you pass a variable to ReactDOM.render(), and if so write an example as to how you can?
ReactDOM.render(
paragraph,
document.getElementById(‘app’)
);