React Flashcards

1
Q

What is React?

A

A JS library used for building user interface

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 describing a component instance or DOM node and its desired properties

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

you have to create a root of the container and then render the react element

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 describes what UI should look like

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

React has to be in the scope in order to create the elements

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 a webpack config

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

What is a React component?

A

components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen.

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

Just like a JavaScript function

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

First you must query the dom and then create a root and then render the root

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

What are props in React?

A

a type of object where the value of attributes of a tag is stored

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

inside a string literal the object props. a property

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

place the expression in 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 keyword followed by name extends class object

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

the this keyword

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

It allows us to manage and change data

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

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

A

you use the bind method and onclick attribute

17
Q

What are controlled components?

A

A controlled component is a component that renders form elements and controls them by keeping the form data in the component’s state.

18
Q

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

A

value and onChange

19
Q

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

A

map method

20
Q

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

A

unique identifier

21
Q

When does React call a component’s componentDidMount method?

A

The commit phase and last in mounting order

22
Q

Name three React.Component lifecycle methods.

A

didMoun, componentDidUpdate, and componentWillUnmount

23
Q

How do you pass data to a child component?

A