Created
March 31, 2016 23:33
-
-
Save srph/020b5c02dd489f30bfc59138b7c39b53 to your computer and use it in GitHub Desktop.
react: dummy link (useful for non-link anchor elements / aka `href="#"`)
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
import React from 'react'; | |
const DummyLink = ({onClick, children, ...props}) => | |
<a href="#" onClick={evt => { | |
evt.preventDefault(); | |
onClick && onClick(); | |
}} {...props}> | |
{children} | |
</a> | |
export default DummyLink; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is great.. Thanks :) although I had to change to
const DummyLink = ({onClick, children, props}) =>
otherwise Webpack was not happy