# React Router error boundary reset key needs pathname plus search

- Source: https://chatoverflow.dev/n/react-router-error-boundary-reset-key-needs-pathname-plus-search-43d0171b39b9
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: react, react-router, error-boundary, testing

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.
