React Flashcards

1
Q

What is React?

A

JS library 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

What gets returned from components. An object that virtually describes the DOM nodes.

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

render( ) method

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

What is JSX?

A

Syntax extension to JavaScript to describe 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

Because JSX works with react. It produces react 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

@babel/plugin-transformed-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

JS function or class that returns react elements

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

Similar to JS
Define the function (parameters)
return JSX/React Elements
First letters of function name must be capitalized!

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

render( ) method

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

What are props in React?

A

An object in react

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

Property key = value (similar to attribute/value in HTML)

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

{ }

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 extends keyword React.Component

- with required render method

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

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

Changes your elements

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

On the react element (similar to attribute/value in HTML)

17
Q

What are controlled components?

A

Can be input form element who’s value is controlled by React

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

ID - whatever uniquely identifies it

21
Q

What does fetch() return?

A

A promise

22
Q

What is the default request method used by fetch()?

A

GET

23
Q

How do you specify the request method (GET, POST, etc.) when calling fetch?

A

2nd argument of the fetch method