HackerTrans
TopNewTrendsCommentsPastAskShowJobs

tkdodo

no profile record

Submissions

TanStack Start v1 Release Candidate

tanstack.com
8 points·by tkdodo·10 เดือนที่ผ่านมา·1 comments

comments

tkdodo
·12 เดือนที่ผ่านมา·discuss
> blindly applying React.memo should be a huge win

That’s what the react compiler does, and it’s a good idea in that case because the compiler knows how to do it correctly, for _everything_. When humans try to do it, they will likely get it wrong (see the real world example in the article, this is the norm imo).
tkdodo
·12 เดือนที่ผ่านมา·discuss
author here , sorry for the confusion. I did not mean to imply that leaving out the prop from useCallback is better - you _always_ have to adhere to the exhaustive-deps lint rule to avoid stale closures (I have a separate blog post on this topic).

What I meant is that the API design of B, where the hook only works as intended if the consumer A memoizes the input props, is not ideal because A has no way of knowing that they have to memoize it unless they look at the implementation or it’s clearly documented (which it rarely is). It’s not A’s problem because B could’ve used the latest ref pattern (or, in the future, useEffectEvent) to work without passing that burden onto its consumers.