React Flashcards
What is prop drilling
prop drilling is when we pass down props from parent to child component in a deeply nested component structure.
What is the context API?
the Context API provides a way to share values between different components, without having to explicitly pass a prop through levels (prop drilling)
What is use useCallback and how does it work?
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
what is a reducer?
A reducer is nothing more than a JS function that takes an action and state and returns a new state.
describe useReducer.
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 do hooks and life cycle methods differ?
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.
what are some drawbacks to the context API
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