Faisal Akbar (@_faisal_akbar) 's Twitter Profile
Faisal Akbar

@_faisal_akbar

Full Stack Problem Solver | Data Storyteller | Bridging Code, Data, and Ideas

ID: 2615159035

linkhttp://dsfaisal.com calendar_today10-07-2014 09:18:46

104 Tweet

106 Followers

1,1K Following

Faisal Akbar (@_faisal_akbar) 's Twitter Profile Photo

🧸 useState() explained to a 5-year-old: It's like a toy box: - box = your state - toys = your data - replacing toys = setState When you put in new toys (setState), React shows everyone your new toys (re-render)! #React #javascript

Faisal Akbar (@_faisal_akbar) 's Twitter Profile Photo

🎓 React useState() Cheatsheet: const [data, setData] = useState(initialValue) 3 Rules to Remember: 1. State updates trigger re-renders 2. State updates are async 3. Previous state? Use callback: setData(prev => prev + 1) #react #javascript

Faisal Akbar (@_faisal_akbar) 's Twitter Profile Photo

🔍 useRef() Cheat Sheet: const ref = useRef(initialValue) 3 Things to Remember: • It's mutable (ref.current) • Changes are instant • Won't trigger re-renders Perfect for: 📍 DOM references ⏱️ Timers 🗃️ Previous values #React #JavaScript

Faisal Akbar (@_faisal_akbar) 's Twitter Profile Photo

🎯 useEffect() Simplified: // Run once useEffect(() => {}, []) // Run on changes useEffect(() => {}, [data]) // Run & cleanup useEffect(() => { return () => cleanup() }, []) No magic, just timing! #ReactJS #javascript

Faisal Akbar (@_faisal_akbar) 's Twitter Profile Photo

🚀 React Hooks: useEffect vs useLayoutEffect useEffect: • Runs after paint • Async, non-blocking • Use for: data fetching, subscriptions • Default choice for most cases useLayoutEffect: • Runs before paint • Sync, blocking • Use for: DOM measurements, preventing flickers

Faisal Akbar (@_faisal_akbar) 's Twitter Profile Photo

🎯 useEffect Cleanup Cheatsheet: • Timers: clearInterval • Events: removeEventListener • Subscriptions: unsubscribe • Connections: disconnect • API: cancel request Always clean what you create! 🚀 Why useEffect Cleanup? No cleanup = Memory leaks Missing cleanup = Bugs

Faisal Akbar (@_faisal_akbar) 's Twitter Profile Photo

🚀 useTransition() - The performance hook you need: • Non-blocking state updates • Background processing • Loading state management • Concurrent rendering ready #react

Faisal Akbar (@_faisal_akbar) 's Twitter Profile Photo

💡JavaScript Tips: Optional Chaining for Safe Property Access const user = { address: { street: "123 Main St" } } // Old way const street = user && user.address && user.address.street // Modern way const street = user?.address?.street