Skip to content

Commit bbdf71a

Browse files
feat(ver): update for react 19 support (#394)
2 parents 64c4864 + ea7d7d1 commit bbdf71a

File tree

84 files changed

+336
-396
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+336
-396
lines changed

.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"eslint:recommended",
1010
"plugin:@typescript-eslint/recommended",
1111
"plugin:react/recommended",
12+
"plugin:react/jsx-runtime",
1213
"plugin:react-hooks/recommended"
1314
],
1415
"parser": "@typescript-eslint/parser",

packages/dev/src/App.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React from 'react';
2-
import ReactDOM from 'react-dom';
1+
import { createRoot } from 'react-dom/client';
32
import App from './AppContext';
43

54
it('renders without crashing', () => {
65
const div = document.createElement('div');
7-
ReactDOM.render(<App />, div);
8-
ReactDOM.unmountComponentAtNode(div);
6+
const root = createRoot(div);
7+
root.render(<App />);
8+
root.unmount();
99
});

packages/dev/src/DefaultCatalog.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { QuickStartCatalogPage, QuickStart } from '@patternfly/quickstarts';
32

43
export const DefaultCatalog = ({ hint }: { hint?: string }) => {

packages/dev/src/FormInput.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { Form, FormGroup, TextInput } from '@patternfly/react-core';
32

43
export const FormInput = ({

packages/dev/src/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as React from 'react';
21
import { createRoot } from 'react-dom/client';
32
import { Route, BrowserRouter, Routes } from 'react-router-dom';
43

packages/dev/src/quickstarts-data/json/monitor-sampleapp-quickstart.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as React from 'react';
21
import { QuickStart } from '@patternfly/quickstarts';
32
import GithubIcon from '@patternfly/react-icons/dist/js/icons/github-icon';
43

packages/dev/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"moduleResolution": "node",
1414
"resolveJsonModule": true,
1515
"isolatedModules": true,
16-
"jsx": "react",
16+
"jsx": "react-jsx",
1717
"strict": true,
1818
"strictPropertyInitialization": false,
1919
"strictNullChecks": false,

packages/module/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
},
4747
"peerDependencies": {
4848
"@patternfly/react-core": "^6.0.0",
49-
"react": "^17 || ^18",
50-
"react-dom": "^17 || ^18",
49+
"react": "^17 || ^18 || ^19",
50+
"react-dom": "^17 || ^18 || ^19",
5151
"marked": "^15.0.6"
5252
},
5353
"dependencies": {
@@ -88,7 +88,6 @@
8888
"react-axe": "^3.5.4",
8989
"react-docgen-typescript-loader": "^3.7.2",
9090
"react-dom": "^18.2.0",
91-
"react-monaco-editor": "0.51.0",
9291
"regenerator-runtime": "^0.13.7",
9392
"rimraf": "^3.0.2",
9493
"rollup": "^2.79.2",

packages/module/patternfly-docs/pages/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { Title, PageSection } from '@patternfly/react-core';
32

43
const centerStyle = {

packages/module/src/ConsoleInternal/components/markdown-view.tsx

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react';
1+
import { FC, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
22
import { css } from '@patternfly/react-styles';
33
import { marked } from 'marked';
44
import { useForceRender } from '@console/shared';
@@ -121,7 +121,7 @@ type InnerSyncMarkdownProps = Pick<SyncMarkdownProps, 'renderExtension' | 'exact
121121
className?: string;
122122
};
123123

124-
export const SyncMarkdownView: React.FC<SyncMarkdownProps> = ({
124+
export const SyncMarkdownView: FC<SyncMarkdownProps> = ({
125125
content,
126126
emptyMsg,
127127
extensions,
@@ -130,10 +130,10 @@ export const SyncMarkdownView: React.FC<SyncMarkdownProps> = ({
130130
inline,
131131
className,
132132
}) => {
133-
const { getResource } = React.useContext<QuickStartContextValues>(QuickStartContext);
134-
const [markup, setMarkup] = React.useState<string>('');
133+
const { getResource } = useContext<QuickStartContextValues>(QuickStartContext);
134+
const [markup, setMarkup] = useState<string>('');
135135

136-
React.useEffect(() => {
136+
useEffect(() => {
137137
async function getMd() {
138138
const md = await markdownConvert(
139139
content || emptyMsg || getResource('Not available'),
@@ -176,8 +176,8 @@ const RenderExtension: React.FC<RenderExtensionProps> = ({
176176
docContext,
177177
}) => {
178178
const forceRender = useForceRender();
179-
const markupRef = React.useRef<string>(null);
180-
const shouldRenderExtension = React.useCallback(() => {
179+
const markupRef = useRef<string>(null);
180+
const shouldRenderExtension = useCallback(() => {
181181
if (markupRef.current === markup) {
182182
return true;
183183
}
@@ -190,7 +190,7 @@ const RenderExtension: React.FC<RenderExtensionProps> = ({
190190
* which causes the component rendered by renderExtension to receive old copy of document
191191
* use forceRender to delay the rendering of extension by one render cycle
192192
*/
193-
React.useEffect(() => {
193+
useEffect(() => {
194194
if (renderExtension) {
195195
forceRender();
196196
}
@@ -201,13 +201,13 @@ const RenderExtension: React.FC<RenderExtensionProps> = ({
201201
);
202202
};
203203

204-
const InlineMarkdownView: React.FC<InnerSyncMarkdownProps> = ({
204+
const InlineMarkdownView: FC<InnerSyncMarkdownProps> = ({
205205
markup,
206206
isEmpty,
207207
renderExtension,
208208
className,
209209
}) => {
210-
const id = React.useMemo(() => uniqueId('markdown'), []);
210+
const id = useMemo(() => uniqueId('markdown'), []);
211211
return (
212212
<div className={css({ 'is-empty': isEmpty } as any, className)} id={id}>
213213
<div dangerouslySetInnerHTML={{ __html: markup }} />
@@ -218,18 +218,18 @@ const InlineMarkdownView: React.FC<InnerSyncMarkdownProps> = ({
218218
);
219219
};
220220

221-
const IFrameMarkdownView: React.FC<InnerSyncMarkdownProps> = ({
221+
const IFrameMarkdownView: FC<InnerSyncMarkdownProps> = ({
222222
exactHeight,
223223
markup,
224224
isEmpty,
225225
renderExtension,
226226
className,
227227
}) => {
228-
const [frame, setFrame] = React.useState<HTMLIFrameElement>();
229-
const [loaded, setLoaded] = React.useState(false);
230-
const updateTimeoutHandle = React.useRef<NodeJS.Timeout>();
228+
const [frame, setFrame] = useState<HTMLIFrameElement>();
229+
const [loaded, setLoaded] = useState(false);
230+
const updateTimeoutHandle = useRef<NodeJS.Timeout>(null);
231231

232-
const updateDimensions = React.useCallback(() => {
232+
const updateDimensions = useCallback(() => {
233233
if (!frame?.contentWindow?.document.body.firstChild) {
234234
return;
235235
}
@@ -248,14 +248,14 @@ const IFrameMarkdownView: React.FC<InnerSyncMarkdownProps> = ({
248248
});
249249
}, [frame, exactHeight]);
250250

251-
React.useEffect(
251+
useEffect(
252252
() => () => {
253253
clearTimeout(updateTimeoutHandle.current);
254254
},
255255
[],
256256
);
257257

258-
const onLoad = React.useCallback(() => {
258+
const onLoad = useCallback(() => {
259259
updateDimensions();
260260
setLoaded(true);
261261
}, [updateDimensions]);
@@ -302,7 +302,9 @@ const IFrameMarkdownView: React.FC<InnerSyncMarkdownProps> = ({
302302
sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin"
303303
srcDoc={contents}
304304
style={{ border: '0px', display: 'block', width: '100%', height: '0' }}
305-
ref={(r) => setFrame(r)}
305+
ref={(r) => {
306+
setFrame(r);
307+
}}
306308
onLoad={() => onLoad()}
307309
className={className}
308310
/>

0 commit comments

Comments
 (0)