Skip to content

Commit ea623ec

Browse files
authored
refactor: replace React.FC with PropsWithChildren (#1194)
* refactor: replace React.FC with PropsWithChildren * refactor: removed React.PropsWithChildren where no children is relevant
1 parent 0c6c2b3 commit ea623ec

File tree

53 files changed

+78
-106
lines changed

Some content is hidden

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

53 files changed

+78
-106
lines changed

README-ru.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ type FetchLoadableData<TData = any> = (blockKey: string) => Promise<TData>;
279279
```jsx
280280
import {Grid, Row, Col} from '@gravity-ui/page-constructor';
281281

282-
const Page: React.FC<PageProps> = ({children}) => (
282+
const Page = ({children}: React.PropsWithChildren<PageProps>) => (
283283
<Grid>
284284
<Row>
285285
<Col sizes={{lg: 4, sm: 6, all: 12}}>{children}</Col>
@@ -295,7 +295,7 @@ const Page: React.FC<PageProps> = ({children}) => (
295295
```jsx
296296
import {Navigation} from '@gravity-ui/page-constructor';
297297

298-
const Page: React.FC<PageProps> = ({data, logo}) => <Navigation data={data} logo={logo} />;
298+
const Page = ({data, logo}: React.PropsWithChildren<PageProps>) => <Navigation data={data} logo={logo} />;
299299
```
300300

301301
### Блоки

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ Usage example:
288288
```jsx
289289
import {Grid, Row, Col} from '@gravity-ui/page-constructor';
290290

291-
const Page: React.FC<PageProps> = ({children}) => (
291+
const Page = ({children}: PropsWithChildren<PageProps>) => (
292292
<Grid>
293293
<Row>
294294
<Col sizes={{lg: 4, sm: 6, all: 12}}>{children}</Col>
@@ -304,7 +304,7 @@ Page navigation can also be used separately from the constructor:
304304
```jsx
305305
import {Navigation} from '@gravity-ui/page-constructor';
306306

307-
const Page: React.FC<PageProps> = ({data, logo}) => <Navigation data={data} logo={logo} />;
307+
const Page= ({data, logo}: React.PropsWithChildren<PageProps>) => <Navigation data={data} logo={logo} />;
308308
```
309309

310310
### Blocks

src/blocks/CardLayout/CardLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export type CardLayoutBlockProps = React.PropsWithChildren<
2121

2222
const b = block('card-layout-block');
2323

24-
const CardLayout: React.FC<CardLayoutBlockProps> = ({
24+
const CardLayout = ({
2525
title,
2626
description,
2727
animated,
@@ -30,7 +30,7 @@ const CardLayout: React.FC<CardLayoutBlockProps> = ({
3030
className,
3131
titleClassName,
3232
background,
33-
}) => {
33+
}: CardLayoutBlockProps) => {
3434
const theme = useTheme();
3535
const {border, ...backgroundImageProps} = getThemedValue(background || {}, theme);
3636
return (

src/blocks/FilterBlock/FilterBlock.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import './FilterBlock.scss';
1313

1414
const b = block('filter-block');
1515

16-
const FilterBlock: React.FC<FilterBlockProps> = ({
16+
const FilterBlock = ({
1717
title,
1818
description,
1919
tags,
@@ -23,7 +23,7 @@ const FilterBlock: React.FC<FilterBlockProps> = ({
2323
colSizes,
2424
centered,
2525
animated,
26-
}) => {
26+
}: FilterBlockProps) => {
2727
const tabButtons = React.useMemo(() => {
2828
const allButton: ButtonTabsItemProps | undefined = allTag
2929
? {id: null, title: typeof allTag === 'boolean' ? i18n('label-all-tag') : allTag}

src/blocks/Form/Form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const b = block('form-block');
2121

2222
const colSizes = {[GridColumnSize.Lg]: 6, [GridColumnSize.All]: 12};
2323

24-
const FormBlock: React.FC<FormBlockProps> = (props) => {
24+
const FormBlock = (props: FormBlockProps) => {
2525
const {formData, title, textContent, direction = FormBlockDirection.Center, background} = props;
2626
const [contentLoaded, setContentLoaded] = React.useState(false);
2727
const isMobile = React.useContext(MobileContext);

src/blocks/Share/Share.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {i18n} from './i18n';
1818
import './Share.scss';
1919

2020
interface IconsProps {
21-
[key: string]: React.FC<React.SVGProps<SVGSVGElement>>;
21+
[key: string]: (props: React.SVGProps<SVGSVGElement>) => React.ReactNode;
2222
}
2323

2424
const icons: IconsProps = {

src/components/ButtonTabs/ButtonTabs.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export interface ButtonTabsProps extends QAProps {
2929
getTabContentElementId?: (tabId: string) => string;
3030
}
3131

32-
const ButtonTabs: React.FC<ButtonTabsProps> = ({
32+
const ButtonTabs = ({
3333
className,
3434
items,
3535
activeTab,
@@ -38,7 +38,7 @@ const ButtonTabs: React.FC<ButtonTabsProps> = ({
3838
qa,
3939
getTabElementId,
4040
getTabContentElementId,
41-
}) => {
41+
}: ButtonTabsProps) => {
4242
const activeTabId: string | null = React.useMemo(() => {
4343
if (activeTab) {
4444
return activeTab;

src/components/Buttons/Buttons.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import * as React from 'react';
2-
31
import {ButtonProps, ContentSize} from '../../models';
42
import {block} from '../../utils';
53
import Button from '../Button/Button';
@@ -27,14 +25,7 @@ function getButtonSize(size: ContentSize) {
2725
}
2826
}
2927

30-
const Buttons: React.FC<ButtonsProps> = ({
31-
className,
32-
titleId,
33-
buttons,
34-
size = 's',
35-
qa,
36-
buttonQa,
37-
}) =>
28+
const Buttons = ({className, titleId, buttons, size = 's', qa, buttonQa}: ButtonsProps) =>
3829
buttons ? (
3930
<div className={b({size}, className)} data-qa={qa}>
4031
{buttons.map((item) => (

src/components/CardBase/CardBase.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ export interface CardFooterBaseProps {
3939

4040
const b = block('card-base-block');
4141

42-
const Header: React.FC<React.PropsWithChildren<CardHeaderBaseProps>> = () => null;
43-
const Content: React.FC<React.PropsWithChildren<{}>> = () => null;
44-
const Footer: React.FC<React.PropsWithChildren<CardFooterBaseProps>> = () => null;
42+
const Header: (props: React.PropsWithChildren<CardHeaderBaseProps>) => React.ReactNode = () => null;
43+
const Content: (props: React.PropsWithChildren<{}>) => React.ReactNode = () => null;
44+
const Footer: (props: React.PropsWithChildren<CardFooterBaseProps>) => React.ReactNode = () => null;
4545

4646
export const Layout = (props: CardBasePropsType) => {
4747
const {

src/components/InnerForm/InnerForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface InnerFormProps {
1717
className?: string;
1818
}
1919

20-
const InnerForm: React.FC<InnerFormProps> = (props) => {
20+
const InnerForm = (props: InnerFormProps) => {
2121
const {formData, onContentLoad, className} = props;
2222
const formsConfig = React.useContext(FormsContext);
2323
const theme = useTheme();

0 commit comments

Comments
 (0)