diff --git a/lib/link.js b/lib/link.js index ee16d7153daa04275b35093aa8610d1c3be68f69..130a1c58d8e41a56e4a44da0ab94f13fe9661226 100644 --- a/lib/link.js +++ b/lib/link.js @@ -127,7 +127,14 @@ export default class Link extends Component { // This will return the first child, if multiple are provided it will throw an error const child = Children.only(children) const props = { - onClick: this.linkClicked + onClick: (e) => { + if (child.props && typeof child.props.onClick === 'function') { + child.props.onClick(e) + } + if (!e.defaultPrevented) { + this.linkClicked(e) + } + } } // If child is an tag and doesn't have a href attribute, or if the 'passHref' property is diff --git a/test/integration/basic/pages/nav/index.js b/test/integration/basic/pages/nav/index.js index 0a364ddfb879d4ccb5e5423b9fbb3e9776f70d46..07b4578a4fff34d876fc8f59791b1e48593eda77 100644 --- a/test/integration/basic/pages/nav/index.js +++ b/test/integration/basic/pages/nav/index.js @@ -38,6 +38,7 @@ export default class extends Component { As Path As Path (No as) As Path (Using Router) + A element with onClick