mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-11-22 14:27:10 +00:00
update WithRoute to handle query params correctly
This commit is contained in:
1 parent
3649099d00
commit
17c426cc91
1 file changed
+7
-3
@@ -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} />;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user