3 ms·
I’ve never liked the <Link> approach. I much prefer to write normal links throughout and intercept clicks globally, which is easier to work with, and every bit
by chrismorgan 4y ago
I’ve never liked the <Link> approach. I much prefer to write normal links throughout and intercept clicks globally, which is easier to work with, and every bit as reliable (more, in some situations). See https://news.ycombinator.com/item?id=31366875 https://news.ycombinator.com/item?id=31366875 for some discussion of this approach, with sample code in https://news.ycombinator.com/item?id=31373486 https://news.ycombinator.com/item?id=31373486.
- tshaddox 4y agoYeah, that works well too, it just isn't as common in component-based frameworks for the reasons pointed out in that thread.
- chrismorgan 4y agoBut I also debunked those reasons in-thread: the URL is fundamentally global state, so there’s no virtue in avoiding a global event handler—in fact, there is virtue in using a global event handler, because the alternative encourages inconsistency, with regular page-load routing accidentally not working in parts of the system (and I’ve definitely seen this happen in real life).