Skip to content

Commit 7d44d82

Browse files
committed
Upgrade react and refactor
1 parent 978e21b commit 7d44d82

File tree

3 files changed

+266
-273
lines changed

3 files changed

+266
-273
lines changed

package.json

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,42 +13,40 @@
1313
"scripts": {
1414
"clean": "rimraf dist/*",
1515
"copy:configs": "copyfiles package.json .npmignore README.md LICENSE ./dist/",
16-
"build": "npm run clean && tsc --project ./tsconfig.json",
17-
"build-to-tutoron": "tsc --project ./tsconfig.json --outDir '/home/vladimir/dev/sources/tutoron/node_modules/react-outside-click-listener'",
18-
"build-to-player": "tsc --project ./tsconfig.json --outDir '/home/vladimir/dev/sources/player/node_modules/react-outside-click-listener'",
16+
"build": "npm run clean && tsc --build ./tsconfig.json",
1917
"patch-publish": "npm run build && npm version patch && npm run copy:configs && npm publish ./dist/ && git push origin master --follow-tags",
2018
"minor-publish": "npm run build && npm version minor && npm run copy:configs && npm publish ./dist/ && git push origin master --follow-tags"
2119
},
2220
"devDependencies": {
23-
"@eslint/compat": "^1.2.1",
24-
"@eslint/eslintrc": "^3.1.0",
25-
"@eslint/js": "^9.13.0",
26-
"@js-toolkit/configs": "^3.93.9",
21+
"@eslint/compat": "^1.2.4",
22+
"@eslint/eslintrc": "^3.2.0",
23+
"@eslint/js": "^9.16.0",
24+
"@js-toolkit/configs": "^3.93.13",
2725
"@types/eslint": "^9.6.1",
2826
"@types/eslint__eslintrc": "^2.1.2",
2927
"@types/eslint__js": "^8.42.3",
30-
"@types/react": "^18.3.11",
31-
"@typescript-eslint/eslint-plugin": "^8.11.0",
32-
"@typescript-eslint/parser": "^8.11.0",
28+
"@types/react": "^19.0.1",
29+
"@typescript-eslint/eslint-plugin": "^8.18.0",
30+
"@typescript-eslint/parser": "^8.18.0",
3331
"copyfiles": "^2.4.1",
34-
"eslint": "^9.13.0",
32+
"eslint": "^9.16.0",
3533
"eslint-config-airbnb": "^19.0.4",
3634
"eslint-config-prettier": "^9.1.0",
3735
"eslint-config-standard": "^17.1.0",
38-
"eslint-import-resolver-typescript": "^3.6.3",
36+
"eslint-import-resolver-typescript": "^3.7.0",
3937
"eslint-plugin-import": "^2.31.0",
40-
"eslint-plugin-jsx-a11y": "^6.10.0",
38+
"eslint-plugin-jsx-a11y": "^6.10.2",
4139
"eslint-plugin-prettier": "^5.2.1",
42-
"eslint-plugin-promise": "^7.1.0",
43-
"eslint-plugin-react": "^7.37.1",
44-
"eslint-plugin-react-hooks": "5.1.0-rc-fb9a90fa48-20240614",
45-
"prettier": "^3.3.3",
46-
"react": "^18.3.1",
40+
"eslint-plugin-promise": "^7.2.1",
41+
"eslint-plugin-react": "^7.37.2",
42+
"eslint-plugin-react-hooks": "5.1.0",
43+
"prettier": "^3.4.2",
44+
"react": "^19.0.0",
4745
"rimraf": "^6.0.1",
48-
"typescript": "^5.6.3",
49-
"typescript-eslint": "^8.10.0"
46+
"typescript": "^5.7.2",
47+
"typescript-eslint": "^8.18.0"
5048
},
5149
"peerDependencies": {
52-
"react": ">= 17.0"
50+
"react": ">= 19"
5351
}
5452
}

src/OutsideClickListener/OutsideClickListener.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22

33
/** Map of elements and selectors */
4-
export type HtmlTagSelectorMap = { [P in keyof JSX.IntrinsicElements]?: string | undefined };
4+
export type HtmlTagSelectorMap = { [P in keyof React.JSX.IntrinsicElements]?: string | undefined };
55

66
export interface OutsideClickListenerProps {
77
/**
@@ -11,7 +11,7 @@ export interface OutsideClickListenerProps {
1111
onOutsideClick: (nativeEvent: Event) => void;
1212
events?: (keyof GlobalEventHandlersEventMap)[];
1313
stopPropagation?: boolean;
14-
children: React.ReactElement & { ref?: React.Ref<Node> };
14+
children: React.ReactElement<React.RefAttributes<Node>>;
1515
/**
1616
* `id` or `Ref` or `Node`.
1717
* The most top parent node of child node to detect outside click.
@@ -89,17 +89,17 @@ export default function OutsideClickListener({
8989
ignoreTopNode,
9090
windowBlurAsOutsideClick,
9191
children,
92-
}: OutsideClickListenerProps): JSX.Element {
92+
}: OutsideClickListenerProps): React.JSX.Element {
9393
const selfNodeRef = React.useRef<Element>(null);
9494
const ignoreRef = React.useRef(ignore);
9595
ignoreRef.current = ignore;
9696

9797
const refHandler = React.useCallback(
9898
(node: Element | null) => {
99-
if (children.ref) setRef(children.ref, node); // pass ref to child ref handler if exists
99+
if (children.props.ref) setRef(children.props.ref, node); // pass ref to child ref handler if exists
100100
setRef(selfNodeRef, node);
101101
},
102-
[children.ref]
102+
[children.props.ref]
103103
);
104104

105105
const outsideClickHandler = React.useCallback<OutsideClickListenerProps['onOutsideClick']>(
@@ -157,5 +157,5 @@ export default function OutsideClickListener({
157157
// eslint-disable-next-line react-hooks/exhaustive-deps
158158
}, [outsideClickHandler, disabled, topNode]);
159159

160-
return <>{React.cloneElement(children, { ref: refHandler })}</>;
160+
return React.cloneElement(children, { ref: refHandler });
161161
}

0 commit comments

Comments
 (0)