79612899

Date: 2025-05-08 17:41:21
Score: 1
Natty:
Report link

This will manually open links in a new tab

<div
  dangerouslySetInnerHTML={{ __html: htmlData }}
  onClick={(event) => {
    const targetLink = event.target;
    
  
    if (targetLink instanceof Element) {
      const anchor = targetLink .closest('a');
      if (anchor && anchor.href) {
        event.preventDefault(); 
        window.open(anchor.href, '_blank', 'noopener,noreferrer');
      }
    }
  }}
/>
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Anurag Singh