React Flashcards

1
Q

What is prop drilling

A

prop drilling is when we pass down props from parent to child component in a deeply nested component structure.

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

What is the context API?

A

the Context API provides a way to share values between different components, without having to explicitly pass a prop through levels (prop drilling)

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

What is use useCallback and how does it work?

A

useCallBack is a hook in react that holds a reference to a function as long as the objects in it’s dependency list do not change. it improves the performance of our components

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

what is a reducer?

A

A reducer is nothing more than a JS function that takes an action and state and returns a new state.

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

describe useReducer.

A

useReducer is a react hook that takes a reducer function and an initial state, and returns a value and a dispatch method. using a reducer to then manage your state is known as the reducer pattern.

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

How do hooks and life cycle methods differ?

A

useEffect hook essentially replaces a lot of the lifecycle methods. Instead of performing tasks in componentDidMount or update, we use useEffect( ) hook, useEffect will immediately call any functions returned it from it. so it replaces componentDidUnMount.

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

what are some drawbacks to the context API

A

We lose some performance optimizations. it’s really a trade off for your application needs. for example, because we’re not as dependent on props we can’t use things like wrapping out react component in a react.Memo

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