function useFriendStatus(friendID) const [isOnline, setIsOnline] = useState(null); useDebugValue(isOnline ? 'Online' : 'Offline'); return isOnline;
return results, isLoading ;
| Anti-Pattern | Why It’s Bad | Better Approach | |--------------|---------------|------------------| | Overly broad dependencies in useCallback | Memoization breaks on every render | Break logic into smaller hooks or use useReducer | | useMemo for simple arithmetic | Wastes memory and CPU | Let it compute; it’s cheap | | useLayoutEffect for data fetching | Blocks paint unnecessarily | useEffect + loading state | | Custom hook that causes cascade re-renders | Returns new object/array each call | Memoize returned object with useMemo | When building custom hooks, React DevTools shows generic "CustomHook" entries. Make them useful with useDebugValue : advanced hook