Created
June 30, 2020 16:08
-
-
Save smitroshin/b1f8989fa3ccb49a57edc8f82060d32b 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