Maintaining href “open in new tab” with an onClick handler in React

前端 未结 5 1674
梦如初夏
梦如初夏 2020-12-13 08:32

I have an onClick (React) handler on a table cell that fires properly, however I want to maintain the \"Open in a new Tab\" feature that having an href on a tag

5条回答
  •  死守一世寂寞
    2020-12-13 08:55

    The answer from @gunn is correct, target="_blank makes the link open in a new tab.

    But this can be a security risk for you page; you can read about it here. There is a simple solution for that: adding rel="noopener noreferrer".

    text
    

提交回复
热议问题