-
-
Save sefgit/33979099029cb7d387d019942cd24108 to your computer and use it in GitHub Desktop.
Simulate native link click programmatically in React.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const simulateNativeLink = (rowData, e) => { | |
if (e.ctrlKey || e.metaKey || e.which === 2 || e.button === 4) { | |
const link = document.createElement('a'); | |
link.target = '_blank'; | |
link.rel = 'noopener noreferrer'; | |
link.href = `/my-orders/${rowData.id}`; | |
link.click(); | |
} else { | |
history.push(`/my-orders/${rowData.id}`); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment