TWIL August 7th 2026
- Even if a helper function isn't an observer itself, if it's used in an observer it re-runs in response to changes
- So you need to convert it to a hook with
useStateto ensure a stable value if that's what you want
- So you need to convert it to a hook with
- You also can't just set it as the initial value of a
useStateoruseRefif you don't want the logic to run- Since those still run on each render despite being discarded
- State in a hook is not kept when the component rendering that hook unmounts (duh)
- But if you set it in your Mobx store on initialization it will
- Took way too long for me to arrive at that solution
- There's something deeply satisfying about writing e2e tests, especially with Playwright's UI mode
- admittedly my
console.log-lead approach to debugging sometimes runs into issues with objects not printing like they would in Firefox - and it's incredibly annoying that I can't even copy text from the snapshots
- but overall I find the experience meditative
- admittedly my
- Before trying to
Navigatesomewhere with React Router, check the origin component actually knows about the destination route- Apparently some codebases have separate entrypoints with access to only a few routes
- Or even no routes despite being wrapped in a Router
- Probably for code-splitting?
- In RSpec, rather than using
allow_any_instance_ofprefer something like this
mockClass = instance_double(klass)
allow(klass).to receive(:new).and_return(mockClass)
allow(mockClass).to receive(:method)
It does fall apart a bit if multiple methods are called on the mocked instance though, since they can't be passed through. Each has to be mocked individually. Promotes testability I guess but if you're working in a complex legacy codebase...
Links
- How the Heck Does JPEG Work? - Shri Khalpada
Another banger from this series, and this time somewhat related to my usual areas of interest!