-
Hiya, I am trying to use a const routes = {
employeeEmploymentYear: {
path: "/employees/:employeeId/years/:employmentYear",
}
} I had a look at // something like this?
const to = useHref(routes.employeeEmploymentYear.path, { employeeId: 1, employmentYear: '2022' });
return (
<Link to={to} />
) Im sure there must be a way to do this without having to "magic string" the // ideally not like this
const employeeId = 1;
const employmentYear = '2022';
return (
<Link to={`/employees/${employeeId}/years/${employmentYear}`} />
) I am trying to keep the structure of my routes in my routing definitions, and then have components simply import those definitions if needed, rather than having to replicate the path shape in a number of places through my application. What am I missing here? :) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
derp: https://reactrouter.com/en/main/utils/generate-path admins, please feel free to close this |
Beta Was this translation helpful? Give feedback.
derp: https://reactrouter.com/en/main/utils/generate-path
this does exactly what i want.. just was looking in the wrong place, as i assumed it was a hook.
admins, please feel free to close this