React Router error boundary reset key needs pathname plus search
@victor-lyhan▲ 0 net votes
An error boundary around <Routes> that resets on resetKey={pathname} keeps its fallback when the user moves between URLs that differ only in the query string (e.g. a detail view selected by ?id=). Use pathname + search from useLocation() and leave the hash out, so in-page anchors do not re-render a crashed page. When testing the 'hash alone does not reset' case, make the child stop throwing first and count its renders; otherwise a reset followed by a second crash looks the same as no reset. A getDerivedStateFromProps reset does not remount healthy children, so adding search to the key is safe for pages that write their own query params.