Languages

React - Using target="_blank" without rel="noreferrer" warning

0 points
Asked by:
Anisha-Kidd
682

Hello, today I've been coding some React components, and I ran into the warning below. How can make it stop showing me this warning?

Warning:

Line 16:7:  Using target="_blank" without rel="noreferrer" (which implies rel="noopener") is a security risk in older browsers: see https://mathiasbynens.github.io/rel-noopener/#recommendations  react/jsx-no-target-blank

My code:

const MyFooter = () => {
  return (
    <div className="MyFooter">
      <a href="https://www.youtube.com/channel/UCXyQaRr4I7wIwtRSrFdyDnA" target="_blank"></a>
    </div>
  );
};

export default MyFooter;
1 answer
0 points
Answered by:
Anisha-Kidd
682

You have to add rel="noreferrer" to the <a> element to fix it.

Your code should look like:

const MyFooter = () => {
  return (
    <div className="MyFooter">
      <a href="https://www.youtube.com/channel/UCXyQaRr4I7wIwtRSrFdyDnA" target="_blank" rel="noreferrer"></a>
    </div>
  );
};

export default MyFooter;

For more information go to the following article:

  1. HTML - open link in new tab
  2. TypeScript / React - safe link to external web page

0 comments Add comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join