0
0
React Nativemobile~5 mins

useCallback optimization in React Native - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of useCallback in React Native?

useCallback helps remember a function so it doesn’t get recreated on every render. This saves work and can make your app faster.

Click to reveal answer
beginner
When should you use useCallback?

Use it when you pass functions to child components that depend on props or state, to avoid unnecessary re-renders.

Click to reveal answer
intermediate
What happens if you forget to add dependencies in useCallback?

The function may use old values and cause bugs because it won’t update when those values change.

Click to reveal answer
intermediate
How does useCallback help with React Native's FlatList performance?

By memoizing item render functions, useCallback prevents unnecessary re-renders of list items, making scrolling smoother.

Click to reveal answer
advanced
Can useCallback always improve performance?

No. If the function is simple or not passed to children, useCallback might add extra work and slow things down.

Click to reveal answer
What does useCallback return?
AA state variable
BA new component
CA memoized version of the callback function
DA side effect
Which of these is a correct use of useCallback?
Aconst memoFn = useCallback(() => doSomething(), [dependency]);
Bconst memoFn = useCallback(doSomething());
Cconst memoFn = useCallback(doSomething, []);
Dconst memoFn = useCallback(() => doSomething());
What is a common mistake when using useCallback?
ANot including dependencies in the array
BUsing it for state variables
CCalling it inside loops
DReturning JSX from it
How does useCallback help child components?
AMakes them load faster
BPrevents them from re-rendering if props don’t change
CChanges their state automatically
DRemoves them from the UI
When might useCallback hurt performance?
AWhen used with state setters
BWhen used with many dependencies
CWhen used inside <code>useEffect</code>
DWhen used on simple functions that don’t change
Explain how useCallback helps optimize React Native apps.
Think about how functions passed to children can cause extra work.
You got /4 concepts.
    Describe common mistakes when using useCallback and their effects.
    What happens if the function uses old values?
    You got /4 concepts.