You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* refactor: modernise build tooling, improve types, and add edge-case tests
- Make onClickAway memoisation-safe using a ref pattern
- Wrap handleBubbledEvents in useCallback for stable child props
- Remove HTMLAttributes extension from Props interface
- Tighten onClickAway event type to FocusEvent | MouseEvent | TouchEvent
- Add package.json exports field for modern ESM/CJS resolution
- Add engines field (node >= 18) and fix prepublishOnly lifecycle hook
- Migrate from Rollup 2 to Rollup 4 with official plugins
- Replace ghooks with husky + lint-staged
- Remove unmaintained dependencies (rimraf, npm-run-all, coveralls)
- Update documentation links from reactjs.org to react.dev
- Add React 19 deprecation note for React.Children.only
- Add tests for callback identity change, nested listeners, and unmount safety
* ci: bump Node to 22 and actions to v4 for semantic-release@25 compat
* ci: consolidate publish workflows into one
* feat: rename bodyEventsToCapture to extraEvents
* ci: add missing OIDC permissions for semantic-release npm publishing
* ci: fetch all history for semantic-release
* fix: update package lock
* chore: add .npmignore to exclude .github folder from npm package
* fix: regenerate package-lock.json to include optional rollup native dependencies
- It's quite **small** in size! Just [')](https://bundlephobia.com/result?p=react-click-away-listener) minified, or [')](https://bundlephobia.com/result?p=react-click-away-listener) minified & gzipp’d.
29
29
- It's built with **TypeScript**.
30
-
- It works with [React Portals](https://reactjs.org/docs/portals.html) ([v2.0.0](https://github.com/ooade/react-click-away-listener/releases/tag/v2.0.0) onwards).
30
+
- It works with [React Portals](https://react.dev/reference/react-dom/createPortal) ([v2.0.0](https://github.com/ooade/react-click-away-listener/releases/tag/v2.0.0) onwards).
31
31
- It supports **mouse**, **touch** and **focus** events.
32
32
33
33
## Usage
@@ -55,7 +55,9 @@ const App = () => {
55
55
56
56
### Caveats
57
57
58
-
[v2.0.0](https://github.com/ooade/react-click-away-listener/releases/tag/v2.0.0) has breaking changes which uses the [`React.Children.only`](https://reactjs.org/docs/react-api.html#reactchildrenonly) API.
58
+
[v2.0.0](https://github.com/ooade/react-click-away-listener/releases/tag/v2.0.0) has breaking changes which uses the [`React.Children.only`](https://react.dev/reference/react/Children#children-only) API.
59
+
60
+
> **Note:**`React.Children.only` is considered a legacy API as of React 19. See the [React docs](https://react.dev/reference/react/Children#alternatives) for details.
59
61
60
62
Thus, the following caveats apply for the `children` of the `<ClickAwayListener>` component:
61
63
@@ -70,7 +72,7 @@ Error: Element type is invalid: expected a string (for built-in components) or a
70
72
Check the render method of `ClickAwayListener`.
71
73
```
72
74
73
-
If you have multiple child components to pass, you can simply wrap them around a [React Fragment](https://reactjs.org/docs/fragments.html) like so:
75
+
If you have multiple child components to pass, you can simply wrap them around a [React Fragment](https://react.dev/reference/react/Fragment) like so:
74
76
75
77
```jsx
76
78
// Assume the `handleClickAway` function is defined.
@@ -83,7 +85,7 @@ If you have multiple child components to pass, you can simply wrap them around a
83
85
</ClickAwayListener>
84
86
```
85
87
86
-
Or if you only have text nodes, you can also wrap them in a [React Fragment](https://reactjs.org/docs/fragments.html) like so:
88
+
Or if you only have text nodes, you can also wrap them in a [React Fragment](https://react.dev/reference/react/Fragment) like so:
87
89
88
90
```jsx
89
91
// Assume the `handleClickAway` function is defined.
@@ -100,10 +102,11 @@ Or if you only have text nodes, you can also wrap them in a [React Fragment](htt
100
102
| mouseEvent | 'click' \|<br/>'mousedown' \|<br/>'mouseup' | 'click' | The mouse event type that gets fired on ClickAway |
101
103
| touchEvent | 'touchstart' \|<br/>'touchend' | 'touchend' | The touch event type that gets fired on ClickAway |
102
104
| focusEvent | 'focusin' \|<br/>'focusout' | 'focusin' | The focus event type that gets fired on ClickAway |
105
+
| extraEvents | Array<keyof DocumentEventMap>|| Extra events to listen for (e.g. `keydown`) |
103
106
104
107
## Examples
105
108
106
-
-[A simple menu built with React Hooks](https://codesandbox.io/s/52384lyo8p)
109
+
-[A simple menu built with React Hooks](https://codesandbox.io/s/52384lyo8p)_(Note: this example may use an older version of React)_
0 commit comments