Skip to content

Commit 47395f9

Browse files
Fix deprecation warnings because of React 18 upgrade
1 parent 67bb694 commit 47395f9

4 files changed

Lines changed: 14 additions & 22 deletions

File tree

src/components/Application/stories/ColorPalettes.stories.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from "react";
2-
import { render } from "react-dom";
32
import { loremIpsum } from "react-lorem-ipsum";
43
import { Meta, StoryFn } from "@storybook/react";
54
import Color from "color";
5+
import { createRoot } from 'react-dom/client';
66

77
import CssCustomProperties from "./../../../common/utils/CssCustomProperties";
88
import {
@@ -194,10 +194,11 @@ const ColorPaletteConfigurator = ({
194194
}, 0 as number);
195195
const warningsTarget = document.getElementById("sumWarnings");
196196
if (warningsTarget) {
197+
const warningsRoot = createRoot(warningsTarget)
197198
if (warnings > 0) {
198-
render(<Badge intent={"warning"}>{warnings}</Badge>, warningsTarget);
199+
warningsRoot.render(<Badge intent={"warning"}>{warnings}</Badge>);
199200
} else {
200-
render(<></>, warningsTarget);
201+
warningsRoot.render(<></>);
201202
}
202203
}
203204
}

src/components/AutocompleteField/AutoCompleteField.tsx

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -160,19 +160,10 @@ export interface SuggestFieldProps<T, UPDATE_VALUE> {
160160
loadMoreResults?: () => Promise<T[] | undefined>;
161161
}
162162

163-
SuggestField.defaultProps = {
164-
autoFocus: false,
165-
disabled: false,
166-
onlyDropdownWithQuery: false, // FIXME: this should be `true` by default, otherwise similarity to `<Select />` is very close
167-
fill: true,
168-
requestErrorPrefix: "",
169-
hasBackDrop: false,
170-
};
171-
172163
/**
173164
* A component with the appearance of an input field that allows to select and optionally create new items.
174165
* It shows suggestions for the entered text from which the user can select any option.
175-
*
166+
*
176167
* It has the following fixed behavior:
177168
*
178169
* - When not focused, a different representation of the item value can be shown, e.g. the label of the value.
@@ -187,21 +178,21 @@ export function SuggestField<T, UPDATE_VALUE>(props: SuggestFieldProps<T, UPDATE
187178
className,
188179
reset,
189180
noResultText,
190-
disabled,
191-
onlyDropdownWithQuery,
181+
disabled = false,
182+
onlyDropdownWithQuery = false, // FIXME: this should be `true` by default, otherwise similarity to `<Select />` is very close
192183
itemValueSelector,
193184
itemRenderer,
194185
onSearch,
195186
onChange,
196187
initialValue,
197-
autoFocus,
188+
autoFocus = false,
198189
createNewItem,
199190
itemValueRenderer,
200191
resetQueryToValue,
201192
itemValueString,
202-
requestErrorPrefix,
203-
hasBackDrop,
204-
fill,
193+
requestErrorPrefix = "",
194+
hasBackDrop = false,
195+
fill = true,
205196
loadMoreResults,
206197
...otherProps
207198
} = props;

src/components/Skeleton/Skeleton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface SkeletonProps {
1515
*/
1616
export function Skeleton({ children }: SkeletonProps) {
1717
const alteredChildren = React.Children.map(children, (child) => {
18-
const originalChild = child as React.ReactElement<{className: string, disabled: boolean, tabIndex: number}>;
18+
const originalChild = child;
1919
if (originalChild.props) {
2020
return React.cloneElement(originalChild, {
2121
className: originalChild.props.className ? originalChild.props.className + " " + SKELETON : SKELETON,

src/extensions/react-flow/nodes/NodeContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from "react";
22
import { Position, useStoreState as getStoreStateFlowV9 } from "react-flow-renderer";
33
import { useStore as getStoreStateFlowV12 } from "@xyflow/react";
44
import Color from "color";
5-
import { Resizable } from "re-resizable";
5+
import {NumberSize, Resizable, ResizeCallback} from "re-resizable";
66

77
import { intentClassName, IntentTypes } from "../../../common/Intent";
88
import { DepictionProps } from "../../../components";
@@ -756,7 +756,7 @@ export function NodeContent<CONTENT_PROPS = React.HTMLAttributes<HTMLElement>>({
756756
}
757757
}, [resizeDirections, originalSize, width, height])
758758

759-
const onResizeStop = React.useCallback((_0:any, _1:any, _2:any, d:any) => {
759+
const onResizeStop: ResizeCallback = React.useCallback((_0, _1, _2, d: NumberSize) => {
760760
const nextWidth = validateWidth((width ?? originalSize.current.width ?? 0) + d.width);
761761
const nextHeight = validateHeight((height ?? originalSize.current.height ?? 0) + d.height);
762762
setWidth(nextWidth);

0 commit comments

Comments
 (0)