I'm trying to get the id of a route from a react.js project like this: page1#view-all
I tried with the native JavaScript document
and window
but unfortunely I can't get it that way because of the SSR.
Is there any alternative to the functions mentioned above? How can I get the router link with the href id? page1#view-all
Thanks
FYI, the errors I'm getting when using document
or window
I'm getting that any of these isn't defined.
Here's a code snippet:
<Link
to="/page1#view-all"
className={`subItem-anchor
${
route && route.split("/")[route.split("/").length - 1] === "all-projects"
? "subnavitemHighlightd"
: ""
}`}
>
route
is actually the other routes such as page1/another-sub-page
but I can't get page1#view-all