diff --git a/package-lock.json b/package-lock.json
index 0b77d720..0dcb5a69 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -17,7 +17,6 @@
"@babel/preset-typescript": "7.21.4",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "14.0.0",
- "@testing-library/react-hooks": "8.0.1",
"@testing-library/user-event": "14.4.3",
"@types/jest": "29.5.0",
"@types/react": "18.0.35",
@@ -30,8 +29,8 @@
"jest": "29.5.0",
"jest-environment-jsdom": "29.5.0",
"prettier": "2.8.7",
- "react": "17.0.2",
- "react-dom": "17.0.2",
+ "react": "18.2.0",
+ "react-dom": "18.2.0",
"react-test-renderer": "17.0.2",
"tsdx": "0.14.1",
"tslib": "2.5.0",
@@ -3185,21 +3184,6 @@
"node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"
}
},
- "node_modules/@testing-library/dom/node_modules/@jest/types/node_modules/chalk": {
- "version": "4.1.2",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "ansi-styles": "^4.1.0",
- "supports-color": "^7.1.0"
- },
- "engines": {
- "node": ">=10"
- },
- "funding": {
- "url": "https://github.com/chalk/chalk?sponsor=1"
- }
- },
"node_modules/@testing-library/dom/node_modules/@types/yargs": {
"version": "16.0.4",
"dev": true,
@@ -3304,35 +3288,6 @@
"react-dom": "^18.0.0"
}
},
- "node_modules/@testing-library/react-hooks": {
- "version": "8.0.1",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "@babel/runtime": "^7.12.5",
- "react-error-boundary": "^3.1.0"
- },
- "engines": {
- "node": ">=12"
- },
- "peerDependencies": {
- "@types/react": "^16.9.0 || ^17.0.0",
- "react": "^16.9.0 || ^17.0.0",
- "react-dom": "^16.9.0 || ^17.0.0",
- "react-test-renderer": "^16.9.0 || ^17.0.0"
- },
- "peerDependenciesMeta": {
- "@types/react": {
- "optional": true
- },
- "react-dom": {
- "optional": true
- },
- "react-test-renderer": {
- "optional": true
- }
- }
- },
"node_modules/@testing-library/user-event": {
"version": "14.4.3",
"dev": true,
@@ -12907,45 +12862,37 @@
}
},
"node_modules/react": {
- "version": "17.0.2",
- "resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz",
- "integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==",
+ "version": "18.2.0",
+ "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz",
+ "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==",
"dev": true,
"dependencies": {
- "loose-envify": "^1.1.0",
- "object-assign": "^4.1.1"
+ "loose-envify": "^1.1.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/react-dom": {
- "version": "17.0.2",
- "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz",
- "integrity": "sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==",
+ "version": "18.2.0",
+ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz",
+ "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==",
"dev": true,
"dependencies": {
"loose-envify": "^1.1.0",
- "object-assign": "^4.1.1",
- "scheduler": "^0.20.2"
+ "scheduler": "^0.23.0"
},
"peerDependencies": {
- "react": "17.0.2"
+ "react": "^18.2.0"
}
},
- "node_modules/react-error-boundary": {
- "version": "3.1.3",
+ "node_modules/react-dom/node_modules/scheduler": {
+ "version": "0.23.0",
+ "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz",
+ "integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==",
"dev": true,
- "license": "MIT",
"dependencies": {
- "@babel/runtime": "^7.12.5"
- },
- "engines": {
- "node": ">=10",
- "npm": ">=6"
- },
- "peerDependencies": {
- "react": ">=16.13.1"
+ "loose-envify": "^1.1.0"
}
},
"node_modules/react-is": {
@@ -18729,16 +18676,6 @@
"@types/node": "*",
"@types/yargs": "^16.0.0",
"chalk": "^4.0.0"
- },
- "dependencies": {
- "chalk": {
- "version": "4.1.2",
- "dev": true,
- "requires": {
- "ansi-styles": "^4.1.0",
- "supports-color": "^7.1.0"
- }
- }
}
},
"@types/yargs": {
@@ -18815,14 +18752,6 @@
"@types/react-dom": "^18.0.0"
}
},
- "@testing-library/react-hooks": {
- "version": "8.0.1",
- "dev": true,
- "requires": {
- "@babel/runtime": "^7.12.5",
- "react-error-boundary": "^3.1.0"
- }
- },
"@testing-library/user-event": {
"version": "14.4.3",
"dev": true,
@@ -25308,31 +25237,33 @@
}
},
"react": {
- "version": "17.0.2",
- "resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz",
- "integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==",
+ "version": "18.2.0",
+ "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz",
+ "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==",
"dev": true,
"requires": {
- "loose-envify": "^1.1.0",
- "object-assign": "^4.1.1"
+ "loose-envify": "^1.1.0"
}
},
"react-dom": {
- "version": "17.0.2",
- "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz",
- "integrity": "sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==",
+ "version": "18.2.0",
+ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz",
+ "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==",
"dev": true,
"requires": {
"loose-envify": "^1.1.0",
- "object-assign": "^4.1.1",
- "scheduler": "^0.20.2"
- }
- },
- "react-error-boundary": {
- "version": "3.1.3",
- "dev": true,
- "requires": {
- "@babel/runtime": "^7.12.5"
+ "scheduler": "^0.23.0"
+ },
+ "dependencies": {
+ "scheduler": {
+ "version": "0.23.0",
+ "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz",
+ "integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==",
+ "dev": true,
+ "requires": {
+ "loose-envify": "^1.1.0"
+ }
+ }
}
},
"react-is": {
diff --git a/package.json b/package.json
index 56c18616..15451bbf 100644
--- a/package.json
+++ b/package.json
@@ -83,7 +83,6 @@
"@babel/preset-typescript": "7.21.4",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "14.0.0",
- "@testing-library/react-hooks": "8.0.1",
"@testing-library/user-event": "14.4.3",
"@types/jest": "29.5.0",
"@types/react": "18.0.35",
@@ -96,8 +95,8 @@
"jest": "29.5.0",
"jest-environment-jsdom": "29.5.0",
"prettier": "2.8.7",
- "react": "17.0.2",
- "react-dom": "17.0.2",
+ "react": "18.2.0",
+ "react-dom": "18.2.0",
"react-test-renderer": "17.0.2",
"tsdx": "0.14.1",
"tslib": "2.5.0",
diff --git a/tests/HotkeysProvider.test.tsx b/tests/HotkeysProvider.test.tsx
index 268a35f1..293e2e53 100644
--- a/tests/HotkeysProvider.test.tsx
+++ b/tests/HotkeysProvider.test.tsx
@@ -1,6 +1,5 @@
-import { render } from '@testing-library/react'
+import { render, act, renderHook } from '@testing-library/react'
import { HotkeysProvider, useHotkeysContext, useHotkeys } from '../src'
-import { act, renderHook } from '@testing-library/react-hooks'
import { ReactNode } from 'react'
import { HotkeysContextType } from '../src/HotkeysProvider'
@@ -189,7 +188,7 @@ test('should update bound hotkeys when useHotkeys changes its scopes', () => {
return {children}
}
- const { result, rerender } = renderHook<{ scopes: string[] }, HotkeysContextType>(
+ const { result, rerender } = renderHook(
({ scopes }) => useIntegratedHotkeys(scopes),
{
// @ts-ignore
diff --git a/tests/useHotkeys.test.tsx b/tests/useHotkeys.test.tsx
index cfda348c..4de1c515 100644
--- a/tests/useHotkeys.test.tsx
+++ b/tests/useHotkeys.test.tsx
@@ -1,12 +1,19 @@
-import { renderHook, WrapperComponent } from '@testing-library/react-hooks'
import userEvent from '@testing-library/user-event'
import { useHotkeys, HotkeysProvider } from '../src'
import { FormTags, HotkeyCallback, Keys, Options } from '../src/types'
-import { DependencyList, MutableRefObject, ReactNode, useCallback, useState } from 'react'
-import { createEvent, fireEvent, render, screen } from '@testing-library/react'
+import {
+ DependencyList,
+ JSXElementConstructor,
+ MutableRefObject,
+ ReactElement,
+ ReactNode,
+ useCallback,
+ useState,
+} from 'react'
+import { createEvent, fireEvent, render, screen, renderHook } from '@testing-library/react'
const wrapper =
- (initialScopes: string[]): WrapperComponent =>
+ (initialScopes: string[]): JSXElementConstructor<{children: ReactElement}> =>
({ children }: { children?: ReactNode }) =>
{children}
@@ -62,7 +69,7 @@ test('should call hotkey when scopes are set but activatedScopes includes wildca
const callback = jest.fn()
const render = (initialScopes: string[] = []) =>
- renderHook(({ keys, options }) => useHotkeys(keys, callback, options), {
+ renderHook(({ keys, options }) => useHotkeys(keys, callback, options), {
wrapper: wrapper(initialScopes),
initialProps: {
keys: 'a',
@@ -82,7 +89,7 @@ test('should not call hotkey when scopes are set but activatedScopes does not in
const callback = jest.fn()
const render = (initialScopes: string[] = []) =>
- renderHook(({ keys, options }) => useHotkeys(keys, callback, options), {
+ renderHook(({ keys, options }) => useHotkeys(keys, callback, options), {
wrapper: wrapper(initialScopes),
initialProps: {
keys: 'a',
@@ -102,7 +109,7 @@ test('should call hotkey when scopes are set and activatedScopes does include so
const callback = jest.fn()
const render = (initialScopes: string[] = []) =>
- renderHook(({ keys, options }) => useHotkeys(keys, callback, options), {
+ renderHook(({ keys, options }) => useHotkeys(keys, callback, options), {
wrapper: wrapper(initialScopes),
initialProps: {
keys: 'a',
@@ -122,7 +129,7 @@ test('should handle multiple scopes', async () => {
const callback = jest.fn()
const render = (initialScopes: string[] = []) =>
- renderHook(({ keys, options }) => useHotkeys(keys, callback, options), {
+ renderHook(({ keys, options }) => useHotkeys(keys, callback, options), {
wrapper: wrapper(initialScopes),
initialProps: {
keys: 'a',
@@ -142,7 +149,7 @@ test('should update call behavior when set scopes change', async () => {
const callback = jest.fn()
const render = (initialScopes: string[] = []) =>
- renderHook(({ keys, options }) => useHotkeys(keys, callback, options), {
+ renderHook(({ keys, options }) => useHotkeys(keys, callback, options), {
wrapper: wrapper(initialScopes),
initialProps: {
keys: 'a',
@@ -168,7 +175,7 @@ test('scope should take precedence over enabled flag/function', async () => {
const callback = jest.fn()
const render = (initialScopes: string[] = []) =>
- renderHook(({ keys, options }) => useHotkeys(keys, callback, options), {
+ renderHook(({ keys, options }) => useHotkeys(keys, callback, options), {
wrapper: wrapper(initialScopes),
initialProps: {
keys: 'a',
@@ -235,7 +242,7 @@ test('should be able to parse first argument as string or array', async () => {
const user = userEvent.setup()
const callback = jest.fn()
- const { rerender } = renderHook(({ keys }) => useHotkeys(keys, callback), {
+ const { rerender } = renderHook(({ keys }) => useHotkeys(keys, callback), {
initialProps: {
keys: 'a, b',
},
@@ -256,7 +263,7 @@ test('should listen to combinations with modifiers', async () => {
const user = userEvent.setup()
const callback = jest.fn()
- const { rerender } = renderHook(({ keys }) => useHotkeys(keys, callback), {
+ const { rerender } = renderHook(({ keys }) => useHotkeys(keys, callback), {
initialProps: {
keys: 'meta+a',
},
@@ -327,7 +334,7 @@ test('should reflect set splitKey character', async () => {
const user = userEvent.setup()
const callback = jest.fn()
- const { rerender } = renderHook>(
+ const { rerender } = renderHook, HookParameters>(
({ keys, options }) => useHotkeys(keys, callback, options),
{
initialProps: { keys: 'a, b', options: undefined },
@@ -638,7 +645,7 @@ test('should bind the event and execute the callback if enabled is set to a func
const user = userEvent.setup()
const callback = jest.fn()
- const { rerender } = renderHook(({ keys, options }) => useHotkeys(keys, callback, options), {
+ const { rerender } = renderHook(({ keys, options }) => useHotkeys(keys, callback, options), {
initialProps: {
keys: 'a',
options: {
diff --git a/tests/useRecordHotkeys.test.tsx b/tests/useRecordHotkeys.test.tsx
index b06a7e79..dddbdf2f 100644
--- a/tests/useRecordHotkeys.test.tsx
+++ b/tests/useRecordHotkeys.test.tsx
@@ -1,4 +1,4 @@
-import { act, renderHook } from '@testing-library/react-hooks'
+import { act, renderHook } from '@testing-library/react'
import useRecordHotkeys from '../src/useRecordHotkeys'
import userEvent from '@testing-library/user-event'