Introducing JSX Flashcards

1
Q

What is JSX?

A

A syntax extension to JavaScript to be used with React to describe what the UI should look like. Example:

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

JSX helps create loosely coupled units called ______?

A

Components

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

What can you put inside the curly braces in JSX?

A

You can put any valid JavaScript expression inside the curly braces in JSX.

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

When JSX is split over multiple lines should it be wrapped in parenthesis?

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

True or False - After compilation, JSX expressions become regular JavaScript function calls and evaluate to JavaScript objects.

A

True! This means that you can use JSX inside of if statements and for loops, assign it to variables, accept it as arguments, and return it from functions.

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

Should you use quotes or curly braces for string values in JSX?

A

You should use quotes for string values and curly braces for expressions.

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

Is the following safe?

A

Yes! By default, React DOM escapes any values embedded in JSX before rendering them. Everything is converted to a string before being rendered. This helps prevent XSS (cross-site-scripting) attacks.

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

What does Babel compile JSX down to?

A

React.createElement() calls. These are identical:

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

React.creatElement() creates “React elements” that are in the end just like everything else in JavaScript, an ______?

A

Object! React reads these objects and uses them to construct the DOM and keep it up to date.

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

What property naming convention is used in JSX instead of HTML attribute names?

A

Since JSX is closer to JavaScript than to HTML, React DOM uses camelCase. For example, class becomes className in JSX, and tabindex becomes tabIndex.

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