I'm upgrading react-router-dom from v5 to v6 and I've encountered a problem.
I have a function which generates a 'to' string:
const generateLinkTo = () => {
switch (widget?.label) { // widget from a useState()
case "Processed shipments":
return "/shipments";
case "Open quote requests":
return "/quote-requests?display_status=open";
default:
return "/";
}
};
However, when I use this in the Link the <a> href is rendered as '/':
<Link to={generateLinkTo} className={`text-decoration-none ${textColor}`}>
...
</Link>
This worked before I updated from react-router-dom v5 to v6.