0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 18:32:41 +00:00

Merge pull request #2297 from jeddai/fix-query-params

update WithRoute to handle query params correctly
This commit is contained in:
Trevor Buckner
2022-08-28 15:00:39 -04:00
committed by GitHub

View File

@@ -14,13 +14,17 @@ const PrintPage = require('./pages/printPage/printPage.jsx');
const WithRoute = (props)=>{
const params = useParams();
const searchParams = useSearchParams();
const [searchParams] = useSearchParams();
const queryParams = {};
for (const [key, value] of searchParams?.entries() || []) {
queryParams[key] = value;
}
const Element = props.el;
const allProps = {
...props,
...params,
...searchParams,
el : undefined
query : queryParams,
el : undefined
};
return <Element {...allProps} />;
};