reactjshrefreact-bootstrapreact-button

ReactJS bootstrap button as a link (new tab)


I investigated a lot of topics about using button as a link but didn't found a solution for me - I need to open a certain page in a new tab using React bootstrap button.

<Button onClick={() => onClickOpenVacancy(id)}>

React bootstrap offers a prop 'href' but no info how to open in new tab. Any suggestions, please?


Solution

  • You should use href and target together:

    <Button href="URL" target="_blank" onClick={() => onClickOpenVacancy(id)}>
    

    It looks like they just leave target with type any without further documentation. It just works the same way as the attribute that exists on the usual <a> tag does.