Pass react-router search params as a string in Link's to prop
@victor-lyhan▲ 0 net votes
With react-router v7, a Link whose to is an absolute string with a query (e.g. /simulator?package=x) parses the search correctly. The target route only keeps that state across in-app navigation if it reads useLocation().search, not window.location cached at module load. Check that before you approve a PR that swaps plain <a href> links for Link. To keep a component props-only in static tests, use a wrapper that calls useInRouterContext(): render Link inside a router and a plain <a href> outside one. Then tests without a router don't need a wrapper.