Skip to content

Commit d379354

Browse files
authored
feat!: add react 19 support (#526)
1 parent dc124f3 commit d379354

File tree

11 files changed

+262
-329
lines changed

11 files changed

+262
-329
lines changed

CHANGELOG.md

Lines changed: 0 additions & 33 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"*.{js,ts,tsx,css,scss,json,md,mdx,yml}": "prettier --write"
2020
},
2121
"devDependencies": {
22-
"husky": "4.3.0",
23-
"lint-staged": "10.5.1",
22+
"husky": "4.3.8",
23+
"lint-staged": "10.5.4",
2424
"prettier": "3.6.2"
2525
},
2626
"version": "6.4.2",

react-responsive-modal/__tests__/index.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react';
1+
import React from 'react';
22
import { fireEvent, render, waitFor } from '@testing-library/react';
33
import { Modal } from '../src';
44
import { describe, it, expect, vitest } from 'vitest';

react-responsive-modal/package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,32 +49,32 @@
4949
}
5050
],
5151
"dependencies": {
52-
"@bedrock-layout/use-forwarded-ref": "^1.3.1",
52+
"@bedrock-layout/use-forwarded-ref": "^2.0.17",
5353
"body-scroll-lock": "^3.1.5",
5454
"classnames": "^2.3.1"
5555
},
5656
"peerDependencies": {
57-
"react": "^16.8.0 || ^17 || ^18",
58-
"react-dom": "^16.8.0 || ^17 || ^18"
57+
"react": "^16.8.0 || ^17 || ^18 || ^19",
58+
"react-dom": "^16.8.0 || ^17 || ^18 || ^19"
5959
},
6060
"devDependencies": {
6161
"@codecov/vite-plugin": "1.9.1",
6262
"@size-limit/preset-small-lib": "11.2.0",
6363
"@testing-library/dom": "10.4.0",
6464
"@testing-library/jest-dom": "6.6.3",
6565
"@testing-library/react": "16.3.0",
66-
"@types/body-scroll-lock": "2.6.1",
67-
"@types/classnames": "2.2.11",
68-
"@types/node": "22.8.2",
69-
"@types/react": "16.9.56",
70-
"@types/react-dom": "16.9.9",
66+
"@types/body-scroll-lock": "2.6.2",
67+
"@types/classnames": "2.3.4",
68+
"@types/node": "22.16.3",
69+
"@types/react": "19.1.8",
70+
"@types/react-dom": "19.1.6",
7171
"@vitejs/plugin-react": "4.6.0",
7272
"@vitest/coverage-istanbul": "3.2.4",
7373
"cypress": "14.5.1",
7474
"jsdom": "26.1.0",
7575
"publint": "0.3.12",
76-
"react": "18.1.0",
77-
"react-dom": "18.1.0",
76+
"react": "19.1.0",
77+
"react-dom": "19.1.0",
7878
"size-limit": "11.2.0",
7979
"tsdown": "0.12.9",
8080
"tslib": "2.8.1",

react-responsive-modal/src/FocusTrap.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import {
88

99
interface FocusTrapProps {
1010
container?: React.RefObject<HTMLElement> | null;
11-
initialFocusRef?: React.RefObject<HTMLElement>;
11+
initialFocusRef?: React.RefObject<HTMLElement | null>;
1212
}
1313

1414
export const FocusTrap = ({ container, initialFocusRef }: FocusTrapProps) => {
15-
const refLastFocus = useRef<HTMLElement | null>();
15+
const refLastFocus = useRef<HTMLElement | null>(null);
1616
/**
1717
* Handle focus lock on the modal
1818
*/

react-responsive-modal/src/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React, { useEffect, useRef, useState } from 'react';
2-
import ReactDom from 'react-dom';
2+
import { createPortal } from 'react-dom';
33
import cx from 'classnames';
4+
import { useForwardedRef } from '@bedrock-layout/use-forwarded-ref';
45
import CloseIcon from './CloseIcon';
56
import { FocusTrap } from './FocusTrap';
67
import { modalManager, useModalManager } from './modalManager';
78
import { useScrollLock } from './useScrollLock';
89
import { isBrowser } from './utils';
9-
import useForwardedRef from '@bedrock-layout/use-forwarded-ref';
1010

1111
const classes = {
1212
root: 'react-responsive-modal-root',
@@ -75,7 +75,7 @@ export interface ModalProps {
7575
*
7676
* Default to undefined.
7777
*/
78-
initialFocusRef?: React.RefObject<HTMLElement>;
78+
initialFocusRef?: React.RefObject<HTMLElement | null>;
7979
/**
8080
* You can specify a container prop which should be of type `Element`.
8181
* The portal will be rendered inside that element.
@@ -310,7 +310,7 @@ export const Modal = React.forwardRef(
310310
: (classNames?.modalAnimationOut ?? classes.modalAnimationOut);
311311

312312
return showPortal && containerModal
313-
? ReactDom.createPortal(
313+
? createPortal(
314314
<div
315315
className={cx(classes.root, classNames?.root)}
316316
style={styles?.root}

react-responsive-modal/src/useScrollLock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useEffect, useRef } from 'react';
22
import { disableBodyScroll, enableBodyScroll } from 'body-scroll-lock';
33

44
export const useScrollLock = (
5-
refModal: React.RefObject<Element>,
5+
refModal: React.RefObject<Element | null>,
66
open: boolean,
77
showPortal: boolean,
88
blockScroll: boolean,

website/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
},
1111
"dependencies": {
1212
"next": "15.3.5",
13-
"react": "18.1.0",
14-
"react-dom": "18.1.0",
13+
"react": "19.1.0",
14+
"react-dom": "19.1.0",
1515
"react-responsive-modal": "workspace:react-responsive-modal"
1616
},
1717
"devDependencies": {
@@ -21,9 +21,9 @@
2121
"@tailwindcss/postcss": "4.1.11",
2222
"@tailwindcss/typography": "0.5.16",
2323
"@types/mdx": "2.0.13",
24-
"@types/node": "22.8.2",
25-
"@types/react": "16.9.56",
26-
"@types/react-dom": "16.9.9",
24+
"@types/node": "22.16.3",
25+
"@types/react": "19.1.8",
26+
"@types/react-dom": "19.1.6",
2727
"fathom-client": "3.7.2",
2828
"highlight.js": "11.11.1",
2929
"postcss": "8.5.6",

website/src/components/ExampleRendered.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import CustomAnimation from '../examples/CustomAnimation';
88
import CustomCloseIcon from '../examples/CustomCloseIcon';
99
import CustomContainer from '../examples/CustomContainer';
1010

11-
const examples: Record<string, () => JSX.Element> = {
11+
const examples: Record<string, () => React.ReactElement> = {
1212
simple: Simple,
1313
multiple: ExampleMultiple,
1414
longContent: LongContent,

website/src/examples/FocusTrappedInitialFocus.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Modal } from 'react-responsive-modal';
33

44
const App = () => {
55
const [open, setOpen] = React.useState(false);
6-
const modalRef = useRef(null);
6+
const modalRef = useRef<HTMLDivElement>(null);
77

88
return (
99
<>

0 commit comments

Comments
 (0)