Replace <a> with <a> breaks the link #1369
-
Hello, I'm trying to change links that come from a random source to local links. Basic V1:
This works, but as the link comes from users inputs (basically), it triggers a full reload even if everything is loaded. V2:
This renders something that looks like a link, but does not navigate.
Does anyone have an idea of what I'm missing please ? =) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 19 replies
-
Welcome @hogoww! 👋
One of the main advantages of React is that it manages when you reload, and generally you shouldn't need to worry about a reload it will be fast (exceptions of course for infinite reloads, compute heavy workloads, and blocking processes).
What do you consider a "local link". Do you mean an absolute path on the same domain? A path relative to the current path? An anchor within the current page? Or something else entirely based off of one of React/Next's many routing systems?
I'm not sure I understand your comment.
Reoccuring theme here, solutions to what? The community is happy to help. |
Beta Was this translation helpful? Give feedback.
-
Small update, I was able to make it work locally, outside of a canvas. |
Beta Was this translation helpful? Give feedback.
-
Hello, |
Beta Was this translation helpful? Give feedback.
There's a lot going wrong here, and there is no framework bug, but there is a good learning opportunity.
The main issue you are running into is order of operations (mousedown before click) and stable identifiers.
Your event handler updates state, which will re-render the component
In the second example you define the
a
function has an anonymous inline function