React Flashcards

1
Q

What is React?

A

A JavaScript library for building user interfaces

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

What is a React element?

A

An object

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

What is JSX?

A

Syntatical sugar that allows HTML elements to be easily created

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

Why must the React object be imported when authoring JSX in a module?

A

b/c React.createElement is being done behind the scenes

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

How can you make Webpack and Babel work together to convert JSX into valid JavaScript?

A

use @babel/react-jsx

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

How do you define a function component in React?

A

Using uppercase, returns a React Element

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

How do you mount a component to the DOM?

A

ReactDOM.render

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

What is a React component?

A

JS like functions that let you split the UI into independent, reusable pieces

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

How do you pass props to a component?

A

add it as a parameter in function, within component call name={value}

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

How do you write JavaScript expressions in JSX?

A

inside curly braces

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

What are props in React?

A

An object

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

What Array method is commonly used to create a list of React elements?

A

Array.map()

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

What is the best value to use as a “key” prop when rendering lists?

A

An object’s id, something that will never repeat or change

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

How do you create “class” component in React?

A

Must use uppercase, extends React.Component, MUST have render method in there where you return the React elements

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

How do you access props in a class component?

A

this.props

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

What are controlled components and how do you work with them?

A

An input form element whose value is controlled by React

-set their values to this.state.value and fire a function every time the value changes to update that in this.state