Week 10 - React Flashcards

1
Q

What is a react component?

A

a function or class that returns a react element that represents a piece of your user interface

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

How do you define a function component in React?

A

Write a JS function with props as a parameter and the rendered react elements as a return
*name of the function needs to be capitalized

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

How do you mount a component to the DOM?

A

Render method of ReactDom

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

What are props in React?

A

props = properties
they are read-only objects used to pass data between react components

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

How do you pass props to a component?

A

pass them in as an argument with the prop name = value

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

How do you write JS expressions in JSX?

A

Surround it with curly braces

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

How do you create a “class” component in react?

A

Class keyword with component name (capitalized), extend React.Component, and define render() method which will return a react element

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
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
9
Q

What is the purpose of state in react?

A

Represents data/information about the component’s current status/situation
allows us to manage changing data in our app

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

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

A

Pass it as a prop of the react element

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

What are controlled components?

A

an input form element whose value is controlled by React

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

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

A

value and onChange

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
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
14
Q

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

A

Ids from data as keys –> it’s a unique identifier

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

What does express.static() return?

A

a function

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

What is the local __dirname variable in a node.js module?

A

It’s a variable that returns the directory name of the current module

17
Q

What does the join() method of Node’s path module do?

A

Joins path segments together and then normalizes the resulting path

18
Q

What does fetch() return?

A

a promise that resolves to a response object

19
Q

What is the default request method used by fetch?

A

‘GET’

20
Q

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

A

specify it in the init object that acts as a 2nd parameter –> if you want to request the method specifically…
- assign the specific method as a string in caps to the method property inside the object
- example: fetch(url, { method: ‘POST’ })