Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
zastrowm
· 4y ago · 0 comments
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.
Comments
[–]
tylerhou
4y ago
Would the dependency linter catch this? I assume yes?
[–]
tpict
4y ago
Yep, it will flag any references to variables in the outer scope that it doesn’t know for certain are stable.
[–]
Rodeoclash
4y ago
Ahh, that's interesting.