Skip to content

Commit 82e8da9

Browse files
authored
Merge pull request #6519 from WiXSL/remove-fc-examples
[RFR] Remove FC usage from examples
2 parents a033ba6 + 1f638d8 commit 82e8da9

Some content is hidden

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

52 files changed

+107
-152
lines changed

examples/demo/src/categories/CategoryEdit.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import { FC } from 'react';
32
import {
43
Datagrid,
54
Edit,
@@ -17,7 +16,8 @@ import ThumbnailField from '../products/ThumbnailField';
1716
import ProductRefField from '../products/ProductRefField';
1817
import { Category } from '../types';
1918

20-
const CategoryTitle: FC<FieldProps<Category>> = ({ record }) => {
19+
const CategoryTitle = (props: FieldProps<Category>) => {
20+
const { record } = props;
2121
const translate = useTranslate();
2222
return record ? (
2323
<span>
@@ -27,7 +27,7 @@ const CategoryTitle: FC<FieldProps<Category>> = ({ record }) => {
2727
) : null;
2828
};
2929

30-
const CategoryEdit: FC<EditProps> = props => (
30+
const CategoryEdit = (props: EditProps) => (
3131
<Edit title={<CategoryTitle />} {...props}>
3232
<SimpleForm>
3333
<TextInput source="name" />

examples/demo/src/categories/CategoryList.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import { FC } from 'react';
32
import { EditButton, List, ListProps, useListContext } from 'react-admin';
43
import inflection from 'inflection';
54
import {
@@ -31,7 +30,7 @@ const useStyles = makeStyles({
3130
},
3231
});
3332

34-
const CategoryGrid: FC = props => {
33+
const CategoryGrid = props => {
3534
const classes = useStyles(props);
3635
const { data, ids } = useListContext<Category>();
3736
return ids ? (
@@ -68,7 +67,7 @@ const CategoryGrid: FC = props => {
6867
) : null;
6968
};
7069

71-
const CategoryList: FC<ListProps> = props => (
70+
const CategoryList = (props: ListProps) => (
7271
<List
7372
{...props}
7473
sort={{ field: 'name', order: 'ASC' }}

examples/demo/src/categories/LinkToRelatedProducts.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import { FC } from 'react';
32
import Button from '@material-ui/core/Button';
43
import { makeStyles } from '@material-ui/core/styles';
54
import { Link } from 'react-router-dom';
@@ -17,7 +16,8 @@ const useStyles = makeStyles({
1716
},
1817
});
1918

20-
const LinkToRelatedProducts: FC<FieldProps<Category>> = ({ record }) => {
19+
const LinkToRelatedProducts = (props: FieldProps<Category>) => {
20+
const { record } = props;
2121
const translate = useTranslate();
2222
const classes = useStyles();
2323
return record ? (

examples/demo/src/dashboard/CardWithIcon.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { FC, createElement } from 'react';
33
import { Card, Box, Typography, Divider } from '@material-ui/core';
44
import { makeStyles } from '@material-ui/core/styles';
55
import { Link } from 'react-router-dom';
6+
import { ReactNode } from 'react';
67

78
import cartouche from './cartouche.png';
89
import cartoucheDark from './cartoucheDark.png';
@@ -12,6 +13,7 @@ interface Props {
1213
to: string;
1314
title?: string;
1415
subtitle?: string | number;
16+
children?: ReactNode;
1517
}
1618

1719
const useStyles = makeStyles(theme => ({
@@ -41,7 +43,7 @@ const useStyles = makeStyles(theme => ({
4143
title: {},
4244
}));
4345

44-
const CardWithIcon: FC<Props> = props => {
46+
const CardWithIcon = (props: Props) => {
4547
const { icon, title, subtitle, to, children } = props;
4648
const classes = useStyles(props);
4749
return (

examples/demo/src/dashboard/Dashboard.tsx

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import React, {
2-
useState,
3-
useEffect,
4-
useCallback,
5-
FC,
6-
CSSProperties,
7-
} from 'react';
1+
import React, { useState, useEffect, useCallback, CSSProperties } from 'react';
82
import { useVersion, useDataProvider } from 'react-admin';
93
import { useMediaQuery, Theme } from '@material-ui/core';
104
import { subDays } from 'date-fns';
@@ -51,7 +45,7 @@ const styles = {
5145
const Spacer = () => <span style={{ width: '1em' }} />;
5246
const VerticalSpacer = () => <span style={{ height: '1em' }} />;
5347

54-
const Dashboard: FC = () => {
48+
const Dashboard = () => {
5549
const [state, setState] = useState<State>({});
5650
const version = useVersion();
5751
const dataProvider = useDataProvider();

examples/demo/src/dashboard/MonthlyRevenue.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import { FC } from 'react';
32
import DollarIcon from '@material-ui/icons/AttachMoney';
43
import { useTranslate } from 'react-admin';
54

@@ -9,7 +8,8 @@ interface Props {
98
value?: string;
109
}
1110

12-
const MonthlyRevenue: FC<Props> = ({ value }) => {
11+
const MonthlyRevenue = (props: Props) => {
12+
const { value } = props;
1313
const translate = useTranslate();
1414
return (
1515
<CardWithIcon

examples/demo/src/dashboard/NbNewOrders.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import { FC } from 'react';
32
import ShoppingCartIcon from '@material-ui/icons/ShoppingCart';
43
import { useTranslate } from 'react-admin';
54

@@ -9,7 +8,8 @@ interface Props {
98
value?: number;
109
}
1110

12-
const NbNewOrders: FC<Props> = ({ value }) => {
11+
const NbNewOrders = (props: Props) => {
12+
const { value } = props;
1313
const translate = useTranslate();
1414
return (
1515
<CardWithIcon

examples/demo/src/dashboard/OrderChart.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import { FC } from 'react';
32
import { Card, CardHeader, CardContent } from '@material-ui/core';
43
import {
54
ResponsiveContainer,
@@ -42,7 +41,8 @@ const getRevenuePerDay = (orders: Order[]): TotalByDay[] => {
4241
}));
4342
};
4443

45-
const OrderChart: FC<{ orders?: Order[] }> = ({ orders }) => {
44+
const OrderChart = (props: { orders?: Order[] }) => {
45+
const { orders } = props;
4646
const translate = useTranslate();
4747
if (!orders) return null;
4848

examples/demo/src/dashboard/PendingOrders.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import { FC } from 'react';
32
import Card from '@material-ui/core/Card';
43
import CardHeader from '@material-ui/core/CardHeader';
54
import List from '@material-ui/core/List';
@@ -28,7 +27,8 @@ const useStyles = makeStyles(theme => ({
2827
},
2928
}));
3029

31-
const PendingOrders: FC<Props> = ({ orders = [], customers = {} }) => {
30+
const PendingOrders = (props: Props) => {
31+
const { orders = [], customers = {} } = props;
3232
const classes = useStyles();
3333
const translate = useTranslate();
3434
return (

examples/demo/src/dashboard/PendingReviews.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import { FC } from 'react';
32
import {
43
Avatar,
54
Box,
@@ -24,7 +23,7 @@ interface Props {
2423
nb?: number;
2524
}
2625

27-
const PendingReviews: FC<Props> = ({ reviews = [], customers = {}, nb }) => {
26+
const PendingReviews = ({ reviews = [], customers = {}, nb }: Props) => {
2827
const classes = useStyles();
2928
const translate = useTranslate();
3029
return (

examples/demo/src/dashboard/Welcome.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import { FC } from 'react';
32
import { Box, Card, CardActions, Button, Typography } from '@material-ui/core';
43
import HomeIcon from '@material-ui/icons/Home';
54
import CodeIcon from '@material-ui/icons/Code';
@@ -37,7 +36,7 @@ const useStyles = makeStyles(theme => ({
3736
},
3837
}));
3938

40-
const Welcome: FC = () => {
39+
const Welcome = () => {
4140
const translate = useTranslate();
4241
const classes = useStyles();
4342
return (

examples/demo/src/invoices/InvoiceList.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import { FC } from 'react';
32
import {
43
List,
54
ListProps,
@@ -30,7 +29,7 @@ const useStyles = makeStyles(theme => ({
3029
},
3130
}));
3231

33-
const InvoiceList: FC<ListProps> = props => {
32+
const InvoiceList = (props: ListProps) => {
3433
const classes = useStyles();
3534
return (
3635
<List

examples/demo/src/invoices/InvoiceShow.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import { FC } from 'react';
32
import Card from '@material-ui/core/Card';
43
import CardContent from '@material-ui/core/CardContent';
54
import Grid from '@material-ui/core/Grid';
@@ -15,7 +14,7 @@ import {
1514
import Basket from '../orders/Basket';
1615
import { Customer, Invoice } from '../types';
1716

18-
const CustomerField: FC<FieldProps<Customer>> = ({ record }) =>
17+
const CustomerField = ({ record }: FieldProps<Customer>) =>
1918
record ? (
2019
<Typography>
2120
{record.first_name} {record.last_name}

examples/demo/src/layout/SubMenu.tsx

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { FC, Fragment, ReactElement } from 'react';
2+
import { Fragment, ReactElement, ReactNode } from 'react';
33
import { useSelector } from 'react-redux';
44
import {
55
List,
@@ -35,16 +35,11 @@ interface Props {
3535
icon: ReactElement;
3636
isOpen: boolean;
3737
name: string;
38+
children: ReactNode;
3839
}
3940

40-
const SubMenu: FC<Props> = ({
41-
handleToggle,
42-
isOpen,
43-
name,
44-
icon,
45-
children,
46-
dense,
47-
}) => {
41+
const SubMenu = (props: Props) => {
42+
const { handleToggle, isOpen, name, icon, children, dense } = props;
4843
const translate = useTranslate();
4944
const classes = useStyles();
5045
const sidebarIsOpen = useSelector<ReduxState, boolean>(

examples/demo/src/orders/Basket.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import { FC } from 'react';
32
import {
43
Table,
54
TableBody,
@@ -16,7 +15,8 @@ const useStyles = makeStyles({
1615
rightAlignedCell: { textAlign: 'right' },
1716
});
1817

19-
const Basket: FC<FieldProps<Order>> = ({ record }) => {
18+
const Basket = (props: FieldProps<Order>) => {
19+
const { record } = props;
2020
const classes = useStyles();
2121
const translate = useTranslate();
2222

examples/demo/src/orders/MobileGrid.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// in src/comments.js
22
import * as React from 'react';
3-
import { FC } from 'react';
43
import { Card, CardHeader, CardContent } from '@material-ui/core';
54
import { makeStyles } from '@material-ui/core/styles';
65
import {
@@ -45,7 +44,8 @@ interface MobileGridProps {
4544
basePath?: string;
4645
}
4746

48-
const MobileGrid: FC<MobileGridProps> = ({ ids, data, basePath }) => {
47+
const MobileGrid = (props: MobileGridProps) => {
48+
const { ids, data, basePath } = props;
4949
const translate = useTranslate();
5050
const classes = useListStyles();
5151

examples/demo/src/orders/OrderEdit.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import { FC } from 'react';
32
import {
43
BooleanInput,
54
DateField,
@@ -32,7 +31,7 @@ interface OrderTitleProps {
3231
record?: Order;
3332
}
3433

35-
const OrderTitle: FC<OrderTitleProps> = ({ record }) => {
34+
const OrderTitle = ({ record }: OrderTitleProps) => {
3635
const translate = useTranslate();
3736
return record ? (
3837
<span>
@@ -228,7 +227,7 @@ const OrderForm = (props: any) => {
228227
/>
229228
);
230229
};
231-
const OrderEdit: FC<EditProps> = props => {
230+
const OrderEdit = (props: EditProps) => {
232231
const classes = useEditStyles();
233232
return (
234233
<Edit

examples/demo/src/orders/OrderList.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { FC, Fragment, useCallback, useEffect, useState } from 'react';
2+
import { Fragment, useCallback, useEffect, useState } from 'react';
33
import {
44
AutocompleteInput,
55
BooleanField,
@@ -87,7 +87,7 @@ const useGetTotals = (filterValues: any) => {
8787
};
8888
};
8989

90-
const TabbedDatagrid: FC<TabbedDatagridProps> = props => {
90+
const TabbedDatagrid = (props: TabbedDatagridProps) => {
9191
const listContext = useListContext();
9292
const { ids, filterValues, setFilters, displayedFilters } = listContext;
9393
const classes = useDatagridStyles();
@@ -259,7 +259,7 @@ const TabbedDatagrid: FC<TabbedDatagridProps> = props => {
259259
);
260260
};
261261

262-
const OrderList: FC<ListProps> = props => (
262+
const OrderList = (props: ListProps) => (
263263
<List
264264
{...props}
265265
filterDefaultValues={{ status: 'ordered' }}

examples/demo/src/orders/Totals.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import { FC } from 'react';
32
import classnames from 'classnames';
43
import { Table, TableBody, TableCell, TableRow } from '@material-ui/core';
54
import { makeStyles } from '@material-ui/core/styles';
@@ -13,7 +12,8 @@ const useStyles = makeStyles({
1312
boldCell: { fontWeight: 'bold' },
1413
});
1514

16-
const Totals: FC<FieldProps<Order>> = ({ record }: { record?: Order }) => {
15+
const Totals = (props: FieldProps<Order>) => {
16+
const { record } = props;
1717
const classes = useStyles();
1818
const translate = useTranslate();
1919

examples/demo/src/products/Aside.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react';
2-
import { FC } from 'react';
32
import inflection from 'inflection';
43
import { Card, CardContent } from '@material-ui/core';
54
import { makeStyles } from '@material-ui/core/styles';
@@ -28,7 +27,7 @@ const useStyles = makeStyles(theme => ({
2827
},
2928
}));
3029

31-
const Aside: FC = () => {
30+
const Aside = () => {
3231
const { data, ids } = useGetList<Category>(
3332
'categories',
3433
{ page: 1, perPage: 100 },

0 commit comments

Comments
 (0)