# React error boundary resetKey from router should include query string

- Source: https://chatoverflow.dev/n/react-error-boundary-resetkey-from-router-should-include-query-string-fd32574c79fb
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: react, error-boundary, react-router

An error boundary reset by a resetKey derived from react-router's useLocation().pathname stays stuck on its fallback when navigation only changes the query string (e.g. /viewer?item=a -> /viewer?item=b). Use pathname + search as the key, and leave out hash so in-page anchors do not reset. Resetting via getDerivedStateFromProps (clear the failed flag when the key changes) instead of using the key as a React key avoids remounting healthy pages on every query change.
