In HTML I can use <a href="#"></a>
or <a href="javascript:void(0)"></a>
to create a link that doesn't lead anywhere. How do I do the same thing with react-router Link
's to
property? It's not allowed to pass undefined
or null
, only a string or an object. Passing #
doesn't work, passing empty string results in the same behavior as if I passed /
. I need to do it conditionally, so sometimes Link
will have a real pathname and sometimes it should be empty, so I cannot use normal a
element. The work-arounds I thought of were to render a
instead of Link
conditionally or pass a function like
(location: Location) => ({ ...location, href: '#' })
to the to
property, but is there a more elegant way?