Get the latest tech news

The Useless UseCallback


Why most memoization is downright useless...

Other ways to fix this include a "we memoize everything all the time" policy, or to have strictly enforced naming convention like a "mustBeMemoized" prefix for props that need to be referentially stable. This custom hook takes an Array of hotkeys as input, and then creates a memoized onKeyDown function, which is passed to an effect. More good news: React has realized that oftentimes, we need imperative access to the latest value of something during a reactive effect without explicitly re-triggering it, so they are going to add this pattern for exactly this use-case as a first class primitive, useEffectEvent.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Useless UseCallback

Useless UseCallback