programmingintermediate

React Hooks Essentials

Learn the most commonly used React Hooks and when to use them

6 cardsFlashcardMaker0 clones
Clone this Deck & Start Studying

Flashcards (6)

Card 1

What is the purpose of useState hook?

useState allows you to add state to functional components. It returns an array with the current state value and a function to update it.
Card 2

When should you use useEffect hook?

useEffect is used for side effects like data fetching, subscriptions, or manually changing the DOM. It runs after render and can clean up on unmount.
Card 3

What does useContext hook do?

useContext allows you to consume context values without wrapping components in Context.Consumer, providing a cleaner way to access shared state.
Card 4

What is the purpose of useRef hook?

useRef creates a mutable reference that persists across re-renders. Commonly used to access DOM elements directly or store mutable values without causing re-renders.
Card 5

When should you use useMemo?

useMemo memoizes expensive calculations, only recomputing when dependencies change. Use it to optimize performance for computationally expensive operations.
Card 6

What is the difference between useMemo and useCallback?

Related Decks