Concepts Flashcards

1
Q

prop drilling

A

AKA threading, sending props from top way down to great-grandchildren to give access-you can use Context to solve it

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

components

A
  • let you split the UI into independent, reusable pieces, and think about each piece in isolation.
  • can be defined as either classes or functions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

props

A

read-only

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

state

A

can be controlled and manipulated by the component

ex. setState used to modify the state in an API call or something similar

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

render

A

-only method required in a class component
-when called will examine this.props and/or this.state
-returns- something- like an element
This will happen at least once
If the components props change, render can happen again
If the components state changes, the render can also happen again

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

update state?

A

use the method this.setState, which passes an object “merge” over the top of the existing state

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

Which lifecycle method is best suited for AJAX calls?

A

componentDidMount- this method executes once after the render method is executed the first time- user sees the page and placeholder data while componentDidMount executes and so you can use setState to update component once date is received

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

binding problem with event handlers

A

in JS class methods, like the ones used for event handlers, are not bound by default, so taking extra steps to bind event handlers is important.

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

solutions to binding problem with methods

A
  1. Use .bind to bind event handler in the class constructor
  2. Use arrow function in JSX (do this in render, rather than class constructor
  3. Change event handler to arrow function class method(similar to the previous method, but in event handler, instead of JSX)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Context

A
  • provides a way to share values like these between components without having to explicitly pass a prop through every level of the tree
  • designed to share data that is considered ‘global’
How well did you know this?
1
Not at all
2
3
4
5
Perfectly