Comment by tiborsaas

6 hours ago

What is cache in this context? useState? What do you mean by cache invalidation in react apps?

Stale closures, perhaps.

  • It never happens if you enable the lint rule.

    • I remember how react team's message, around the time hooks were introduced, was how hooks were going to save us from the tyranny of `this`, which people presumably found confusing.

      I often think back to that message, while adding things in a dependency array. Especially those things that I know won't change (e.g. the redux `dispatch` function pulled from the context), but the linter doesn't. Or while being admonished by the linter for reading from a ref, or writing to it.