diff --git a/example/src/pages/index.js b/example/src/pages/index.js index 69eba39..0adaef8 100644 --- a/example/src/pages/index.js +++ b/example/src/pages/index.js @@ -120,6 +120,13 @@ class Index extends Component { and give us a dark theme when we get there.
+ console.log('Link clicked')} + > + Go to page 2 normally (with an `onClick`) + +
diff --git a/example/src/pages/page-2.js b/example/src/pages/page-2.js index 1fba7e2..e1f979c 100644 --- a/example/src/pages/page-2.js +++ b/example/src/pages/page-2.js @@ -137,6 +137,13 @@ export default class SecondPage extends Component { 👉 +
+ console.log('Link clicked')} + > + Go home normally (with an `onClick`) +
{ return ( @@ -22,7 +23,7 @@ const TransitionLink = ({ activeStyle={activeStyle} style={style} className={className} - onClick={event => + onClick={event => { triggerTransition({ event, to, @@ -30,7 +31,11 @@ const TransitionLink = ({ entry, ...context }) - } + + if (typeof onClick === 'function') { + onClick(event) + } + }} to={to} // use gatsby link so prefetching still happens. this is prevent defaulted in triggertransition {...rest} >