Skip to content

Commit d844e24

Browse files
committed
fix: update react imports for linter
1 parent 42109d4 commit d844e24

File tree

58 files changed

+497
-171
lines changed

Some content is hidden

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

58 files changed

+497
-171
lines changed

common/postMessage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {useEffect} from 'react';
1+
import * as React from 'react';
22

33
import {ActionMessageTypes, EventMessageTypes, PostMessageAPIMessage} from './types';
44

@@ -37,7 +37,7 @@ export function usePostMessageAPIListener<K extends keyof EventMessageTypes>(
3737
callback: (data: EventMessageTypes[K]) => void,
3838
deps: unknown[] = [],
3939
) {
40-
useEffect(() => {
40+
React.useEffect(() => {
4141
return listenPostMessageEvents(action, callback);
4242
}, [...deps]);
4343
}

editor-v2/components/DynamicForm/DynamicForm.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import _ from 'lodash';
2-
import React, {useCallback} from 'react';
2+
import * as React from 'react';
33

44
import {ConfigInput, DynamicFormValue} from '../../../common/types';
55
import {editorCn} from '../../utils/cn';
@@ -27,7 +27,7 @@ interface DynamicFormProps {
2727
const DynamicForm = ({blockConfig, onUpdate, contentConfig}: DynamicFormProps) => {
2828
const inputs = blockConfig;
2929

30-
const getData = useCallback(
30+
const getData = React.useCallback(
3131
(variable: string) => {
3232
if (variable.startsWith('block.')) {
3333
const purePath = variable.replace('block.', '');
@@ -47,7 +47,7 @@ const DynamicForm = ({blockConfig, onUpdate, contentConfig}: DynamicFormProps) =
4747
[contentConfig],
4848
);
4949

50-
const decide = useCallback(
50+
const decide = React.useCallback(
5151
(showIf: string): boolean => {
5252
const parts = showIf.split(' ');
5353

@@ -71,7 +71,7 @@ const DynamicForm = ({blockConfig, onUpdate, contentConfig}: DynamicFormProps) =
7171
[getData],
7272
);
7373

74-
const renderInput = useCallback(
74+
const renderInput = React.useCallback(
7575
(input: ConfigInput) => {
7676
const fieldPath = input.name;
7777
const fieldValue = getContent(contentConfig, input.name);

editor-v2/components/DynamicForm/FieldBase/FieldBase.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {ArrowRotateLeft} from '@gravity-ui/icons';
22
import {ArrowToggle, Button, Icon} from '@gravity-ui/uikit';
33
import _ from 'lodash';
4-
import React, {PropsWithChildren, useState} from 'react';
4+
import * as React from 'react';
55

66
import {editorCn} from '../../../utils/cn';
77

@@ -16,7 +16,7 @@ export interface FieldBaseParams {
1616
expandable?: boolean;
1717
}
1818

19-
export interface FieldBaseProps extends PropsWithChildren, FieldBaseParams {
19+
export interface FieldBaseProps extends React.PropsWithChildren, FieldBaseParams {
2020
className?: string;
2121
}
2222

@@ -28,7 +28,7 @@ const FieldBase: React.FC<FieldBaseProps> = ({
2828
onRefresh,
2929
expandable = false,
3030
}) => {
31-
const [showChildren, setShowChildren] = useState(!expandable);
31+
const [showChildren, setShowChildren] = React.useState(!expandable);
3232

3333
const titleComponent = React.useMemo(() => {
3434
if (title) {

editor-v2/components/DynamicForm/Fields/Array/Array.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Plus} from '@gravity-ui/icons';
22
import {Button, Card, Icon} from '@gravity-ui/uikit';
3-
import React, {useCallback} from 'react';
3+
import * as React from 'react';
44

55
import {ArrayObjectInput, ArrayTextInput, DynamicFormValue} from '../../../../../common/types';
66
import {removeFromArray, swapArrayItems} from '../../../../utils';
@@ -27,15 +27,15 @@ interface ArrayFieldProps {
2727
const ArrayDynamicField = ({title, values, onUpdate, className, blockConfig}: ArrayFieldProps) => {
2828
const haveItems = values && Array.isArray(values) && values.length;
2929

30-
const onAddItem = useCallback(() => {
30+
const onAddItem = React.useCallback(() => {
3131
if (blockConfig.arrayType === 'text') {
3232
onUpdate('', haveItems ? [...values, ''] : ['']);
3333
} else if (blockConfig.arrayType === 'object') {
3434
onUpdate('', haveItems ? [...values, {}] : [{}]);
3535
}
3636
}, [blockConfig.arrayType, haveItems, onUpdate, values]);
3737

38-
const onDeleteItem = useCallback(
38+
const onDeleteItem = React.useCallback(
3939
(index: number) => {
4040
if (Array.isArray(values)) {
4141
const newArray = removeFromArray(values, index);
@@ -45,7 +45,7 @@ const ArrayDynamicField = ({title, values, onUpdate, className, blockConfig}: Ar
4545
[onUpdate, values],
4646
);
4747

48-
const onReorderItem = useCallback(
48+
const onReorderItem = React.useCallback(
4949
(index: number, placement: 'up' | 'down') => {
5050
if (Array.isArray(values)) {
5151
const newArray = swapArrayItems(
@@ -59,7 +59,7 @@ const ArrayDynamicField = ({title, values, onUpdate, className, blockConfig}: Ar
5959
[onUpdate, values],
6060
);
6161

62-
const renderInput = useCallback(
62+
const renderInput = React.useCallback(
6363
(value: DynamicFormValue, index: number) => {
6464
const arrayItemButton = (
6565
<ItemButton
@@ -113,7 +113,7 @@ const ArrayDynamicField = ({title, values, onUpdate, className, blockConfig}: Ar
113113
[blockConfig, haveItems, onDeleteItem, onReorderItem, onUpdate, values],
114114
);
115115

116-
const renderInputs = useCallback(() => {
116+
const renderInputs = React.useCallback(() => {
117117
if (haveItems) {
118118
const renderItems = values
119119
.map(renderInput)

editor-v2/components/DynamicForm/Fields/Array/ItemButton/ItemButton.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {ArrowDown, ArrowUp, EllipsisVertical, TrashBin} from '@gravity-ui/icons';
22
import {Button, Icon, Menu, Popup} from '@gravity-ui/uikit';
3-
import React, {Fragment, useCallback, useRef, useState} from 'react';
3+
import * as React from 'react';
44

55
import {editorCn} from '../../../../../utils/cn';
66

@@ -23,18 +23,18 @@ const ItemButton = ({
2323
disableReorderUp = false,
2424
disableReorderDown = false,
2525
}: ItemButtonProps) => {
26-
const buttonRef = useRef(null);
27-
const [isOpen, setIsOpen] = useState(false);
26+
const buttonRef = React.useRef(null);
27+
const [isOpen, setIsOpen] = React.useState(false);
2828

29-
const onMenuItemClickWrapper = useCallback((callback: () => void) => {
29+
const onMenuItemClickWrapper = React.useCallback((callback: () => void) => {
3030
return () => {
3131
setIsOpen(false);
3232
callback();
3333
};
3434
}, []);
3535

3636
return (
37-
<Fragment>
37+
<React.Fragment>
3838
<Button className={b(null, className)} ref={buttonRef} onClick={() => setIsOpen(true)}>
3939
<Icon data={EllipsisVertical} />
4040
</Button>
@@ -68,7 +68,7 @@ const ItemButton = ({
6868
</Menu.Item>
6969
</Menu>
7070
</Popup>
71-
</Fragment>
71+
</React.Fragment>
7272
);
7373
};
7474

editor-v2/components/DynamicForm/Fields/Boolean/Boolean.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {Switch} from '@gravity-ui/uikit';
2-
import React from 'react';
32

43
import {editorCn} from '../../../../utils/cn';
54
import FieldBase, {FieldBaseParams} from '../../FieldBase/FieldBase';

editor-v2/components/DynamicForm/Fields/Number/Number.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {TextInput} from '@gravity-ui/uikit';
2-
import React from 'react';
32

43
import {editorCn} from '../../../../utils/cn';
54
import FieldBase, {FieldBaseParams} from '../../FieldBase/FieldBase';

editor-v2/components/DynamicForm/Fields/Object/Object.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {Card} from '@gravity-ui/uikit';
2-
import React from 'react';
32

43
import {ConfigInput, DynamicFormValue} from '../../../../../common/types';
54
import {editorCn} from '../../../../utils/cn';

editor-v2/components/DynamicForm/Fields/OneOf/OneOf.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {Card, RadioButton} from '@gravity-ui/uikit';
2-
import React, {useCallback, useMemo, useState} from 'react';
1+
import {Card, SegmentedRadioGroup} from '@gravity-ui/uikit';
2+
import * as React from 'react';
33

44
import {DynamicFormValue, OneOfInput} from '../../../../../common/types';
55
import {editorCn} from '../../../../utils/cn';
@@ -33,18 +33,18 @@ const OneOfDynamicField = ({
3333
}: OneOfDynamicFieldProps) => {
3434
const defaultValue = inputConfig.options[0].value;
3535

36-
const [oneOfMetaValue, setOneOfMetaValue] = useState(defaultValue);
36+
const [oneOfMetaValue, setOneOfMetaValue] = React.useState(defaultValue);
3737

3838
const oneOfContentConfig = getOneOfContentConfig(contentConfig, inputConfig.name);
39-
const oneOfChosenOption = useMemo(
39+
const oneOfChosenOption = React.useMemo(
4040
() =>
4141
inputConfig.options.find(
4242
({value: foundOneOfValue}) => foundOneOfValue === oneOfMetaValue,
4343
),
4444
[inputConfig.options, oneOfMetaValue],
4545
);
4646

47-
const onUpdateOneOf = useCallback((value: string) => {
47+
const onUpdateOneOf = React.useCallback((value: string) => {
4848
setOneOfMetaValue(value);
4949
}, []);
5050

@@ -56,7 +56,7 @@ const OneOfDynamicField = ({
5656
expandable
5757
>
5858
<Card className={b('card')}>
59-
<RadioButton
59+
<SegmentedRadioGroup
6060
className={b('radio')}
6161
options={inputConfig.options.map((option) => ({
6262
content: option.title,

editor-v2/components/DynamicForm/Fields/Select/Select.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import {RadioButton, Select} from '@gravity-ui/uikit';
2-
import React from 'react';
1+
import {SegmentedRadioGroup, Select} from '@gravity-ui/uikit';
32

43
import {SelectMultipleInput, SelectSingleInput} from '../../../../../common/types';
54
import {editorCn} from '../../../../utils/cn';
@@ -30,7 +29,7 @@ const SelectDynamicField = ({input, value, onUpdate, className}: SelectDynamicFi
3029
/>
3130
)}
3231
{inputView === 'radiobutton' && (
33-
<RadioButton options={input.enum} value={value} onUpdate={onUpdate} />
32+
<SegmentedRadioGroup options={input.enum} value={value} onUpdate={onUpdate} />
3433
)}
3534
</FieldBase>
3635
);

0 commit comments

Comments
 (0)