React Flashcards

1
Q

What is React?

A

A component-based JavaScript library that helps with building user interfaces dynamically.
Combines design and logic layers into one process

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

What is a React element?

A

a plain object that describes and HTML element (also a DOM node) is used in the React DOM to update the DOM

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

How do you mount a React element to the DOM?

A

calling the render method of the root object, and passing in the result of the createElement method of the React object

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

What is JSX?

A

A syntax extension to JavaScript that produces React elements with HTML-like syntax

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

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

A

JSX is part of the React library

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

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

A

Using the babel loader with the plugin-transform-react-jsx

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

What is a React component?

A

Pieces of the UI that accept arbitrary inputs (called “props”) and return JSX, and are reusable in nature

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

How do you define a function component in React?

A

A JavaScript function, name starting with a capital letter, that accepts a single property object as an argument and returns JSX

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

How do you mount a component to the DOM?

A

the render method of the root object with an argument of the return value of the function component

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

What are props in React?

A

Any JSX value or object that is passed into a component as an argument

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

How do you pass props to a component?

A

As an argument

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

How do you write JavaScript expressions in JSX?

A

By placing the expression inside of curly braces

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

How do you create “class” component in React?

A

class ClassName extends React.Component {
render() {
return ;
}
}

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

How do you access props in a class component?

A

this.props.propName;

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

What is the purpose of state in React?

A

To designate the conditions for how a component will render. If the state changes, the conditions change

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

How do you pass an event handler to a React element?

A

By setting it as a prop inside of curly braces

17
Q

What are controlled components?

A

An input form element whose value is controlled by React in changing the state

18
Q

What two props must you pass to an input for it to be “controlled”?

A

value, onChange

19
Q

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

A

map()

20
Q

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

A

IDs from data