Skip to content
Better HN
Top
Best
Ask
Show
New
Jobs
Search
⌘K
0 points
zastrowm
3y ago
0 comments
Save
Share
For this specific example the problem is that the
handleClick
callback is using a stale/cached
onImageDeleted
callback (which indirectly has old state). If you add
onImageDeleted
to the
handleClick
dependency array, it beings to work as you expect.
0 comments
3 comments · 2 top-level
top
newest
oldest
tylerhou
3y ago
· 1 in thread
Would the dependency linter catch this? I assume yes?
tpict
3y ago
Yep, it will flag any references to variables in the outer scope that it doesn’t know for certain are stable.
Rodeoclash
3y ago
Ahh, that's interesting.
j
/
k
navigate · click thread line to collapse