React Flashcards

1
Q

What is the difference between DOM and Virtual DOM?

A

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

What is React?

A

A javascript library

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

What are the pros and cons of React?

A

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

What are hooks?

A

..

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

Lifecycles?

A

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

Explain useEffect().

A

Similar to componentDidMount, componentDidUpdate, and componentDidUnMount. It’s called after mounting. It saves the initial state inside it.

Creates a side-effect that either needs cleanup or doesn’t need cleanup.

Return a callback function to unmount/cleanup.

Use multiple useEffect() for separate concerns.

useEffect takes in two parameters (callback, [dependency value(s)]).

Pass an empty [] to run only once on mount and cleanup on unmount. If you don’t pass variables that are useEffect is dependent on, next time it runes the stale variables will cause weird shit.

Pass a [count] to only re-run the effect if count changes.

Passing no [] at all will cause useEffect to run every single render. It’ll trigger the effect and update state, and because the updated state causes a re-render, useEffect will run again, causing an infinite loop. Don’t pass nothing!

Examples:

  • Set up subscriptions
  • Clean up timers
  • Change the value of a ref
  • Fetch data

Link: https://daveceddia.com/useeffect-hook-examples/

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

useState()

A

..

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

What is the DOM?

A

Document Object Model.

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

What is React Query?

A

Makes fetching, caching, synchronizing, and updating server state in React applications easy.

Caching… (possibly the hardest thing to do in programming, but game-changing)
Deduping multiple requests for the same data into a single request
Updating out of date data in the background
Controlling when data is “out of date”
Performance optimizations like pagination and lazy loading data
Managing memory and garbage collection of server state
Optimistic updates and rollbacks for “instant” UI and user experiences.

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