0

I am using Link from react-router-dom package to make my semantic-ui-react <Dropdown.Item> component open in new tab some url. First my problem was that when I was clicking on this component, in new tab, url that I wanted to go to was appended to my localhost route, and I found the solution here on SO: https://stackoverflow.com/a/47447458/5833816. There it says that I should add // before my url, so not 'https://someurl.com' but '//https://someurl.com'

But applying this solution did not help entirely. Now in new tab url is not appended to already existing localhost url but instead of being opened with 'https://someurl.com' it opens 'http//someurl.com' - so, without :

Here is code: Component:

<Dropdown.Item
    as={Link}
    to={url} // url was 'https://someurl.com', now is '//https://someurl.com'
    target={newTab ? '_blank' : ''} // newTab's value is true
    replace={newTab}
    className='contextDropdownItem'
    onClick={onClick}
    disabled={disabled}
  >

When I click on this dropdown menu item browser opens new tab, but url is http//someurl.com without :

Version of semantic-ui-react: 0.81.1, react: 16.4.1, react-router-dom: 4.3.1

Lazar Nikolic
  • 2,798
  • 1
  • 14
  • 29

1 Answers1

0

React-router doesn't support external links. Check out React-Router External link for a few ideas of how to get around this, but I tend to use standard <a href='...'>.

R. Wright
  • 764
  • 3
  • 9