React Flashcards

1
Q

What is React?

A

javascript framework for building composable UIs

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

What are some features of React?

A
  • JSX: ui language that allows us to write html inside of JS
  • virtual DOM: bc writing to the DOM is expensive
  • composable UI
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the Virtual DOM

A

an in memory representation of the real DOM and it syncs against the real DOM. The virtual DOM allows for cheaper and faster and more frequent updates

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

When does the Virtual DOM sync against the real DOM?

A

After render() is called but before UI appears on screen

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

How does the VirtualDOM work?

A
  • when data changes, the entire UI in the vDOM updates
  • then React calculates the diff between the vDOM and real DOM
  • then the real DOM updates accordingly
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is JSX?

A

It’s the UI language that allows us to write html with javascript

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

Difference between state and props

A
  • state is managed by the component
  • props are passed into the component
  • state re-renders the UI when updated
  • props should be immutable and for configuration only
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When should you use a callback function in setState() ?

A

When you have to perform an asynchronous task

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

What are the 3 phases of the component lifecycle?

A
  • mount
  • update
  • unmount
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are contexts?

A

tool to pass data w/o prop drilling. good for things like user auth or preferences

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

What is a custom hook?

A

A function that allows us to “hook” into React’s state and lifecycle updates

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