Introduction Flashcards

1
Q

What is React?

A

React is a JavaScript Library.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are JSX elements treated as?

A

JSX is a syntax extension for JavaScript

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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)

A

You need to add parenthesis around the code, like so:

Const myDiv = (
<div>
  <h1>Hello world</h1>


</div>


);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is one one key thing that a JSX expression must have, what is this?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How would you render a JSX expression? (Make it appear on screen)

A

ReactDOM.render(

<h1>Color</h1>

,
document.getElementById(‘app’)
);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Can you pass a variable to ReactDOM.render(), and if so write an example as to how you can?

A

ReactDOM.render(
paragraph,
document.getElementById(‘app’)
);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly