MCPcopy
hub / github.com/vercel/next.js / onClick

Function onClick

packages/next/src/client/app-dir/link.tsx:642–678  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

640 } = {
641 ref: mergedRef,
642 onClick(e) {
643 if (process.env.NODE_ENV !== 'production') {
644 if (!e) {
645 throw new Error(
646 `Component rendered inside next/link has to pass click event to "onClick" prop.`
647 )
648 }
649 }
650
651 if (!legacyBehavior && typeof onClick === 'function') {
652 onClick(e)
653 }
654
655 if (
656 legacyBehavior &&
657 child.props &&
658 typeof child.props.onClick === 'function'
659 ) {
660 child.props.onClick(e)
661 }
662
663 if (!router) {
664 return
665 }
666 if (e.defaultPrevented) {
667 return
668 }
669 linkClicked(
670 e,
671 formattedHref,
672 linkInstanceRef,
673 replace,
674 scroll,
675 onNavigate,
676 transitionTypes
677 )
678 },
679 onMouseEnter(e) {
680 if (!legacyBehavior && typeof onMouseEnterProp === 'function') {
681 onMouseEnterProp(e)

Callers

nothing calls this directly

Calls 1

linkClickedFunction · 0.70

Tested by

no test coverage detected