Please, Use a Link
4 hours ago
- #SPA_critique
- #user_experience
- #web_development
- The author encountered a navigation issue in an internal single-page app, where clicking the browser's back button unexpectedly closed the app and displayed Chrome's default tab page.
- The article criticizes developers for misusing elements like <div> and <button> with onclick event handlers to mimic links, instead of using the proper HTML anchor tag (<a href='...'>).
- It explains the advantages of native links, including built-in browser support, default styling, hover previews, mobile interactions, and accessibility without extra work.
- The author highlights common mistakes in React apps, where developers use functions like navigate() with location.replace(), leading to broken browser history.
- A solution is offered: using native anchor tags or React Router's Link component to ensure proper navigation and maintain browser history functionality.