Readit News logoReadit News
joelg commented on The Useless UseCallback   tkdodo.eu/blog/the-useles... · Posted by u/0xedb
strogonoff · a month ago
I would describe the reasons to useMemo or useCallback as follows, in order of decreasing importance: 1) referential equality of non-primitives (any object, function, etc.) passed downstream as props and 2) expensive computation. The first one is for me non-optional, and I’ll focus on that (as the second one is self-explanatory).

Once you know about the reactive render cycle, it becomes a second nature to never create any object other than via a memo function with declared dependencies. Anything else—any instance of something like <Component someProp={[1, 2, 3]} />—is, to me, just a bug on the caller side, not something to be accommodated.

Furthermore, ensuring referential equality has benefits beyond avoiding re-renders (which I would acknowledge should generally be harmless, although are in practice a source of hard to spot issues and loops on occasion).

— First, it serves as a clarity aid and documentation for yourself. It helps maintain a mental graph like “caller-provided props A and B are used to compute prop C for a downstream component”. Code organized this way tends to have self-evident refactor routes, and logic naturally localizes into cohesive sub-blocks with clearly defined inputs and outputs.

— Second, and it is obviously an ES runtime thing, but it is simply weird to have to reason about objects being essentially the same but different—and if memoization allows me to not have to do it and, with some discipline, make it safe to assume that (() => true) is the same as (() => true), why pass on that opportunity?

That said, now that I see an alternative take on this, I will make sure to document my approach in the development guidelines section of the README.

joelg · a month ago
yeah I completely agree, I think there's a whole logic of reasons to using useEffect/useCallback/useMemo that the post didn't acknowledge.

personally, I want to have a comprehensive understanding of exactly when and why each of my components re-renders, and to do that I use hooks and design around referential equality. like you said, it's a kind of documentation, more about organization than performance.

not to say that this way is intrinsically better! just that the style is appealing for its own reasons

Deleted Comment

joelg commented on Facts don't change minds, structure does   vasily.cc/blog/facts-dont... · Posted by u/staph
joelg · a month ago
my understanding (which is definitely not exhaustive!) is that the case between Galileo and the church was way more nuanced than is popularly retold, and had nothing whatsoever to do with Biblical literalism like the passage in Joshua about making the sun stand still.

Paul Feyerabend has a book called Against Method in which he essentially argues that it was the Catholic Church who was following the classical "scientific method" of weighing evidence between theories, and Galileo's hypothesis was rationally judged to be inferior to the existing models. Very fun read.

joelg commented on Visualizing 13M Bluesky users   joelgustafson.com/posts/2... · Posted by u/joelg
declan_roberts · 9 months ago
Bluesky to me still seems like a place completely dominated by software type (HN crowd). I know there are obvious exceptions there's no need for you to list them.

Threads has extreme normies, bluesky has the nerds, and twitter seems to have just the right mixture of both.

joelg · 9 months ago
one of my biggest subjective takeaways from spending hours scrolling around the map is that my impression that the userbase was dominated by software types was ~mostly wrong! feels like less than half, and the rest is huge swaths of normie, artist, furry, and media people
joelg commented on Visualizing 13M Bluesky users   joelgustafson.com/posts/2... · Posted by u/joelg
andreygrehov · 9 months ago
Is the "scraper" still running? If so, how many users are there today?
joelg · 9 months ago
there are a other few places tracking those stats too; I just counted 14487454 in my database :)
joelg commented on Apple already shipped attestation on the web, and we barely noticed   httptoolkit.com/blog/appl... · Posted by u/pimterry
modeless · 2 years ago
Yesterday, the sentiment on Google's early proposal was "company breakups start to make a lot of sense", "Go f yourself, Google", "It's maddening and saddening", "[the people involved] reputations are fully gone from this".

Today it turns out Apple not only proposed but implemented and shipped the actual feature last year. "It could be an interesting opportunity to reboot a few long-lost dreams". "I kind of get both sides here". "I guess I personally come down to leaving this turned on in Safari for now, and seeing what happens". Granted, the overall sentiment is still negative but the difference in tone is stark. The reality distortion field is alive and well, folks.

joelg · 2 years ago
point taken, but as the blog post here and many other comments have pointed out, there is a very sharp qualitative difference between just-Apple and Apple+Google doing this. Apple alone has a minority market share but together they cover enough of the market that many websites would be tempted to only allow connections from trusted clients.

u/joelg

KarmaCake day1497October 5, 2015
About
https://joelgustafson.com
View Original