Link does not take to the correct URL in reactjs Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30 pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Which “href” value should I use for JavaScript links, “#” or “javascript:void(0)”?Encode URL in JavaScript?Get current URL with jQuery?How does JavaScript .prototype work?How do I modify the URL without reloading the page?Get the current URL with JavaScript?What does “use strict” do in JavaScript, and what is the reasoning behind it?Why does Google prepend while(1); to their JSON responses?Open a URL in a new tab (and not a new window) using JavaScriptHow does data binding work in AngularJS?

Why doesn't the university give past final exams' answers?

All ASCII characters with a given bit count

What does the black goddess statue do and what is it?

Are there existing rules/lore for MTG planeswalkers?

In search of the origins of term censor, I hit a dead end stuck with the greek term, to censor, λογοκρίνω

What's the difference between using dependency injection with a container and using a service locator?

France's Public Holidays' Puzzle

How long can a nation maintain a technological edge over the rest of the world?

false 'Security alert' from Google - every login generates mails from 'no-reply@accounts.google.com'

Why does Java have support for time zone offsets with seconds precision?

What to do with someone that cheated their way though university and a PhD program?

How would it unbalance gameplay to rule that Weapon Master allows for picking a fighting style?

What were wait-states, and why was it only an issue for PCs?

How did Elite on the NES work?

What is the ongoing value of the Kanban board to the developers as opposed to management

Why did Europeans not widely domesticate foxes?

Retract an already submitted Recommendation Letter (written for an undergrad student)

Writing a T-SQL stored procedure to receive 4 numbers and insert them into a table

Co-worker works way more than he should

Where to find documentation for `whois` command options?

My admission is revoked after accepting the admission offer

Will I be more secure with my own router behind my ISP's router?

Test if all elements of a Foldable are the same

How would you suggest I follow up with coworkers about our deadline that's today?



Link does not take to the correct URL in reactjs



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30 pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Which “href” value should I use for JavaScript links, “#” or “javascript:void(0)”?Encode URL in JavaScript?Get current URL with jQuery?How does JavaScript .prototype work?How do I modify the URL without reloading the page?Get the current URL with JavaScript?What does “use strict” do in JavaScript, and what is the reasoning behind it?Why does Google prepend while(1); to their JSON responses?Open a URL in a new tab (and not a new window) using JavaScriptHow does data binding work in AngularJS?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2















I am learning Reactjs, and there is a problem when I try to use Link to go to external websites.



<Link to=repo.html_url>
repo.name
</Link>


Let's say the repo.html_url is
https://github.com/ningmeng7998/SmartER-Project-Android-Frontend.

Instead of taking me to this URL, it takes me to http://localhost:3000/profile/https://github.com/ningmeng7998/SmartER-Project-Android-Frontend, which adds localhost in front of it.



How to solve this problem?










share|improve this question
























  • The primary way to allow users to navigate around your application

    – Maheer Ali
    Mar 9 at 4:46

















2















I am learning Reactjs, and there is a problem when I try to use Link to go to external websites.



<Link to=repo.html_url>
repo.name
</Link>


Let's say the repo.html_url is
https://github.com/ningmeng7998/SmartER-Project-Android-Frontend.

Instead of taking me to this URL, it takes me to http://localhost:3000/profile/https://github.com/ningmeng7998/SmartER-Project-Android-Frontend, which adds localhost in front of it.



How to solve this problem?










share|improve this question
























  • The primary way to allow users to navigate around your application

    – Maheer Ali
    Mar 9 at 4:46













2












2








2








I am learning Reactjs, and there is a problem when I try to use Link to go to external websites.



<Link to=repo.html_url>
repo.name
</Link>


Let's say the repo.html_url is
https://github.com/ningmeng7998/SmartER-Project-Android-Frontend.

Instead of taking me to this URL, it takes me to http://localhost:3000/profile/https://github.com/ningmeng7998/SmartER-Project-Android-Frontend, which adds localhost in front of it.



How to solve this problem?










share|improve this question
















I am learning Reactjs, and there is a problem when I try to use Link to go to external websites.



<Link to=repo.html_url>
repo.name
</Link>


Let's say the repo.html_url is
https://github.com/ningmeng7998/SmartER-Project-Android-Frontend.

Instead of taking me to this URL, it takes me to http://localhost:3000/profile/https://github.com/ningmeng7998/SmartER-Project-Android-Frontend, which adds localhost in front of it.



How to solve this problem?







javascript reactjs react-router






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 9 at 7:28









Bruno Ely

488417




488417










asked Mar 9 at 4:44









NingNing

203




203












  • The primary way to allow users to navigate around your application

    – Maheer Ali
    Mar 9 at 4:46

















  • The primary way to allow users to navigate around your application

    – Maheer Ali
    Mar 9 at 4:46
















The primary way to allow users to navigate around your application

– Maheer Ali
Mar 9 at 4:46





The primary way to allow users to navigate around your application

– Maheer Ali
Mar 9 at 4:46












2 Answers
2






active

oldest

votes


















2














I'm assuming you're using React Router's Link component, as it is not part of vanilla React.



Currently, React Router Links do not support external URLs, they're just for navigating internally in your app. You'll want to use a standard HTML anchor tag. Try this:



<a href=repo.html_url>repo.name</a>


There's some discussion going on around the issue of Links supporting external URLs going on here if you'd like to learn more or stay in the loop.



Another solution is to implement your own wrapper around Link that handles the logic (and in the end spits out a <Link> component for internal routes or <a> tag for external URLs).






share|improve this answer


















  • 1





    That's why. Got it. Thanks a lot!

    – Ning
    Mar 9 at 5:02






  • 1





    @Ning consider accepting as answer if something solved your problem

    – Code Maniac
    Mar 9 at 5:12


















1














For external links, just use a tag! as <Link> is only used for internal routes. As you can see in the docs that React Router themselves used a tags for an external link instead of Link.



<a href=repo.html_url>
repo.name
</a>





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55074063%2flink-does-not-take-to-the-correct-url-in-reactjs%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    I'm assuming you're using React Router's Link component, as it is not part of vanilla React.



    Currently, React Router Links do not support external URLs, they're just for navigating internally in your app. You'll want to use a standard HTML anchor tag. Try this:



    <a href=repo.html_url>repo.name</a>


    There's some discussion going on around the issue of Links supporting external URLs going on here if you'd like to learn more or stay in the loop.



    Another solution is to implement your own wrapper around Link that handles the logic (and in the end spits out a <Link> component for internal routes or <a> tag for external URLs).






    share|improve this answer


















    • 1





      That's why. Got it. Thanks a lot!

      – Ning
      Mar 9 at 5:02






    • 1





      @Ning consider accepting as answer if something solved your problem

      – Code Maniac
      Mar 9 at 5:12















    2














    I'm assuming you're using React Router's Link component, as it is not part of vanilla React.



    Currently, React Router Links do not support external URLs, they're just for navigating internally in your app. You'll want to use a standard HTML anchor tag. Try this:



    <a href=repo.html_url>repo.name</a>


    There's some discussion going on around the issue of Links supporting external URLs going on here if you'd like to learn more or stay in the loop.



    Another solution is to implement your own wrapper around Link that handles the logic (and in the end spits out a <Link> component for internal routes or <a> tag for external URLs).






    share|improve this answer


















    • 1





      That's why. Got it. Thanks a lot!

      – Ning
      Mar 9 at 5:02






    • 1





      @Ning consider accepting as answer if something solved your problem

      – Code Maniac
      Mar 9 at 5:12













    2












    2








    2







    I'm assuming you're using React Router's Link component, as it is not part of vanilla React.



    Currently, React Router Links do not support external URLs, they're just for navigating internally in your app. You'll want to use a standard HTML anchor tag. Try this:



    <a href=repo.html_url>repo.name</a>


    There's some discussion going on around the issue of Links supporting external URLs going on here if you'd like to learn more or stay in the loop.



    Another solution is to implement your own wrapper around Link that handles the logic (and in the end spits out a <Link> component for internal routes or <a> tag for external URLs).






    share|improve this answer













    I'm assuming you're using React Router's Link component, as it is not part of vanilla React.



    Currently, React Router Links do not support external URLs, they're just for navigating internally in your app. You'll want to use a standard HTML anchor tag. Try this:



    <a href=repo.html_url>repo.name</a>


    There's some discussion going on around the issue of Links supporting external URLs going on here if you'd like to learn more or stay in the loop.



    Another solution is to implement your own wrapper around Link that handles the logic (and in the end spits out a <Link> component for internal routes or <a> tag for external URLs).







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 9 at 4:54









    Bruno ElyBruno Ely

    488417




    488417







    • 1





      That's why. Got it. Thanks a lot!

      – Ning
      Mar 9 at 5:02






    • 1





      @Ning consider accepting as answer if something solved your problem

      – Code Maniac
      Mar 9 at 5:12












    • 1





      That's why. Got it. Thanks a lot!

      – Ning
      Mar 9 at 5:02






    • 1





      @Ning consider accepting as answer if something solved your problem

      – Code Maniac
      Mar 9 at 5:12







    1




    1





    That's why. Got it. Thanks a lot!

    – Ning
    Mar 9 at 5:02





    That's why. Got it. Thanks a lot!

    – Ning
    Mar 9 at 5:02




    1




    1





    @Ning consider accepting as answer if something solved your problem

    – Code Maniac
    Mar 9 at 5:12





    @Ning consider accepting as answer if something solved your problem

    – Code Maniac
    Mar 9 at 5:12













    1














    For external links, just use a tag! as <Link> is only used for internal routes. As you can see in the docs that React Router themselves used a tags for an external link instead of Link.



    <a href=repo.html_url>
    repo.name
    </a>





    share|improve this answer



























      1














      For external links, just use a tag! as <Link> is only used for internal routes. As you can see in the docs that React Router themselves used a tags for an external link instead of Link.



      <a href=repo.html_url>
      repo.name
      </a>





      share|improve this answer

























        1












        1








        1







        For external links, just use a tag! as <Link> is only used for internal routes. As you can see in the docs that React Router themselves used a tags for an external link instead of Link.



        <a href=repo.html_url>
        repo.name
        </a>





        share|improve this answer













        For external links, just use a tag! as <Link> is only used for internal routes. As you can see in the docs that React Router themselves used a tags for an external link instead of Link.



        <a href=repo.html_url>
        repo.name
        </a>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 9 at 4:53









        Vaibhav MuleVaibhav Mule

        3,14112546




        3,14112546



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55074063%2flink-does-not-take-to-the-correct-url-in-reactjs%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

            Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

            Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved