Back to articles
Promises, Data Flow, and the memo + useCallback Combo That Actually Makes React Fast

Promises, Data Flow, and the memo + useCallback Combo That Actually Makes React Fast

via Dev.to JavaScriptJalaj Bankar

A big session with some genuinely advanced React in the second half. The memo and useCallback combination is one of those things that looks complicated but makes complete sense once you understand why it exists. .then() Can Handle Rejections Too — Not Just .catch() Most people only use .catch() for errors and .then() for success. But .then() actually accepts two functions — one for success, one for rejection: promise .then(successFn) // handles success only .then(successFn, errorFn) // handles both .catch(errorFn) // handles rejection only Here's the quick reference: .then(successFn) — success ✅, rejection ❌ skipped .then(successFn, errorFn) — success ✅, rejection ✅ .catch(errorFn) — success ❌ skipped, rejection ✅ And the other thing worth locking in — whatever you return inside a .then() gets passed down to the next .then() or .catch() waiting below it. The chain is just values being handed down one step at a time. React Data Flow — The Parent is Always in Charge A few rules that are

Continue reading on Dev.to JavaScript

Opens in a new tab

Read Full Article
6 views

Related Articles