rsnext/packages
Adam Pietrasiak 41706d6fd3
Require component rendered as child of Link to pass event to onClick handler (#27723)
Currently, if you render `next/link` like

```ts
<Link>
  <CustomComponent />
</Link>
```

and have 

```tsx
interface Props {
  onClick?: () => void; // <— note we're not passing event as an argument
}

function CustomComponent({ onClick }: Props) {
  return <div onClick={() => onClick?.()}>Hello</div>
}
```

It'll result in error

```
link.js?f421:21 Uncaught TypeError: Cannot read property 'defaultPrevented' of undefined
```

<!--
Thanks for opening a PR! Your contribution is much appreciated.
In order to make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below.
Choose the right checklist for the change that you're making:
-->

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-02-07 00:04:37 +00:00
..
create-next-app fix(cna): add default version (#33006) 2022-02-06 15:03:35 -06:00
eslint-config-next v12.0.11-canary.6 2022-02-04 17:02:00 -06:00
eslint-plugin-next v12.0.11-canary.6 2022-02-04 17:02:00 -06:00
next Require component rendered as child of Link to pass event to onClick handler (#27723) 2022-02-07 00:04:37 +00:00
next-bundle-analyzer v12.0.11-canary.6 2022-02-04 17:02:00 -06:00
next-codemod v12.0.11-canary.6 2022-02-04 17:02:00 -06:00
next-env v12.0.11-canary.6 2022-02-04 17:02:00 -06:00
next-mdx v12.0.11-canary.6 2022-02-04 17:02:00 -06:00
next-plugin-storybook v12.0.11-canary.6 2022-02-04 17:02:00 -06:00
next-polyfill-module v12.0.11-canary.6 2022-02-04 17:02:00 -06:00
next-polyfill-nomodule v12.0.11-canary.6 2022-02-04 17:02:00 -06:00
next-swc v12.0.11-canary.6 2022-02-04 17:02:00 -06:00
react-dev-overlay v12.0.11-canary.6 2022-02-04 17:02:00 -06:00
react-refresh-utils v12.0.11-canary.6 2022-02-04 17:02:00 -06:00