Common React Hooks Flashcards

(11 cards)

1
Q

Define useState.

A

A Hook that lets you add state to functional components.

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

What does useEffect do?

A

It allows you to perform side effects in function components.

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

True or false: useContext provides a way to pass data through the component tree.

A

TRUE

It avoids prop drilling by allowing components to access context directly.

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

Fill in the blank: useReducer is used for managing _______ in React.

A

complex state logic

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

What is the purpose of useMemo?

A

It memoizes a computed value to optimize performance.

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

Define useCallback.

A

A Hook that returns a memoized callback function.

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

What does useRef return?

A

A mutable ref object whose .current property is initialized to the passed argument.

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

True or false: useLayoutEffect runs synchronously after all DOM mutations.

A

TRUE

It is useful for reading layout from the DOM and synchronously re-rendering.

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

Fill in the blank: useImperativeHandle customizes the instance value that is _______.

A

exposed to parent components

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

What is the main use of useDebugValue?

A

To display a label for custom hooks in React DevTools.

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

Define useTransition.

A

A Hook that allows you to mark updates as transitions for better user experience.

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