React Hooks Flashcards
1
Q
What is the purpose of the useState hook?
A
It lets you add state to functional components.
2
Q
What does the useEffect hook do?
A
It performs side effects (like data fetching, DOM manipulation, etc.) in functional components.
3
Q
Explain the useReducer hook and its use cases.
A
useReducer is an alternative to useState that’s more suited for managing complex state logic. It accepts a reducer function and an initial state, returning the current state paired with a dispatch method.