reroute
This commit is contained in:
16
src/components/kunde/withEntityRoute.jsx
Normal file
16
src/components/kunde/withEntityRoute.jsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import { useParams } from 'react-router-dom';
|
||||
|
||||
/** Injects numeric `entityId` from `/kunde/:entityId`. */
|
||||
export default function withEntityRoute(Wrapped) {
|
||||
function EntityRouteWrapper(props) {
|
||||
const { entityId: raw } = useParams();
|
||||
const entityId = Number(raw);
|
||||
return (
|
||||
<Wrapped
|
||||
{...props}
|
||||
entityId={Number.isInteger(entityId) ? entityId : null}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return EntityRouteWrapper;
|
||||
}
|
||||
Reference in New Issue
Block a user