Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFR] Remove FC usage from examples #6519

Merged
merged 5 commits into from
Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/demo/src/categories/CategoryEdit.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { FC } from 'react';
import {
Datagrid,
Edit,
Expand All @@ -17,7 +16,8 @@ import ThumbnailField from '../products/ThumbnailField';
import ProductRefField from '../products/ProductRefField';
import { Category } from '../types';

const CategoryTitle: FC<FieldProps<Category>> = ({ record }) => {
const CategoryTitle = (props: FieldProps<Category>) => {
const { record } = props;
const translate = useTranslate();
return record ? (
<span>
Expand All @@ -27,7 +27,7 @@ const CategoryTitle: FC<FieldProps<Category>> = ({ record }) => {
) : null;
};

const CategoryEdit: FC<EditProps> = props => (
const CategoryEdit = (props: EditProps) => (
<Edit title={<CategoryTitle />} {...props}>
<SimpleForm>
<TextInput source="name" />
Expand Down
5 changes: 2 additions & 3 deletions examples/demo/src/categories/CategoryList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { FC } from 'react';
import { EditButton, List, ListProps, useListContext } from 'react-admin';
import inflection from 'inflection';
import {
Expand Down Expand Up @@ -31,7 +30,7 @@ const useStyles = makeStyles({
},
});

const CategoryGrid: FC = props => {
const CategoryGrid = props => {
const classes = useStyles(props);
const { data, ids } = useListContext<Category>();
return ids ? (
Expand Down Expand Up @@ -68,7 +67,7 @@ const CategoryGrid: FC = props => {
) : null;
};

const CategoryList: FC<ListProps> = props => (
const CategoryList = (props: ListProps) => (
<List
{...props}
sort={{ field: 'name', order: 'ASC' }}
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/src/categories/LinkToRelatedProducts.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { FC } from 'react';
import Button from '@material-ui/core/Button';
import { makeStyles } from '@material-ui/core/styles';
import { Link } from 'react-router-dom';
Expand All @@ -17,7 +16,8 @@ const useStyles = makeStyles({
},
});

const LinkToRelatedProducts: FC<FieldProps<Category>> = ({ record }) => {
const LinkToRelatedProducts = (props: FieldProps<Category>) => {
const { record } = props;
const translate = useTranslate();
const classes = useStyles();
return record ? (
Expand Down
4 changes: 3 additions & 1 deletion examples/demo/src/dashboard/CardWithIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FC, createElement } from 'react';
import { Card, Box, Typography, Divider } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import { Link } from 'react-router-dom';
import { ReactNode } from 'react';

import cartouche from './cartouche.png';
import cartoucheDark from './cartoucheDark.png';
Expand All @@ -12,6 +13,7 @@ interface Props {
to: string;
title?: string;
subtitle?: string | number;
children?: ReactNode;
}

const useStyles = makeStyles(theme => ({
Expand Down Expand Up @@ -41,7 +43,7 @@ const useStyles = makeStyles(theme => ({
title: {},
}));

const CardWithIcon: FC<Props> = props => {
const CardWithIcon = (props: Props) => {
const { icon, title, subtitle, to, children } = props;
const classes = useStyles(props);
return (
Expand Down
10 changes: 2 additions & 8 deletions examples/demo/src/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import React, {
useState,
useEffect,
useCallback,
FC,
CSSProperties,
} from 'react';
import React, { useState, useEffect, useCallback, CSSProperties } from 'react';
import { useVersion, useDataProvider } from 'react-admin';
import { useMediaQuery, Theme } from '@material-ui/core';
import { subDays } from 'date-fns';
Expand Down Expand Up @@ -51,7 +45,7 @@ const styles = {
const Spacer = () => <span style={{ width: '1em' }} />;
const VerticalSpacer = () => <span style={{ height: '1em' }} />;

const Dashboard: FC = () => {
const Dashboard = () => {
const [state, setState] = useState<State>({});
const version = useVersion();
const dataProvider = useDataProvider();
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/src/dashboard/MonthlyRevenue.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { FC } from 'react';
import DollarIcon from '@material-ui/icons/AttachMoney';
import { useTranslate } from 'react-admin';

Expand All @@ -9,7 +8,8 @@ interface Props {
value?: string;
}

const MonthlyRevenue: FC<Props> = ({ value }) => {
const MonthlyRevenue = (props: Props) => {
const { value } = props;
const translate = useTranslate();
return (
<CardWithIcon
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/src/dashboard/NbNewOrders.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { FC } from 'react';
import ShoppingCartIcon from '@material-ui/icons/ShoppingCart';
import { useTranslate } from 'react-admin';

Expand All @@ -9,7 +8,8 @@ interface Props {
value?: number;
}

const NbNewOrders: FC<Props> = ({ value }) => {
const NbNewOrders = (props: Props) => {
const { value } = props;
const translate = useTranslate();
return (
<CardWithIcon
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/src/dashboard/OrderChart.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { FC } from 'react';
import { Card, CardHeader, CardContent } from '@material-ui/core';
import {
ResponsiveContainer,
Expand Down Expand Up @@ -42,7 +41,8 @@ const getRevenuePerDay = (orders: Order[]): TotalByDay[] => {
}));
};

const OrderChart: FC<{ orders?: Order[] }> = ({ orders }) => {
const OrderChart = (props: { orders?: Order[] }) => {
const { orders } = props;
const translate = useTranslate();
if (!orders) return null;

Expand Down
4 changes: 2 additions & 2 deletions examples/demo/src/dashboard/PendingOrders.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { FC } from 'react';
import Card from '@material-ui/core/Card';
import CardHeader from '@material-ui/core/CardHeader';
import List from '@material-ui/core/List';
Expand Down Expand Up @@ -28,7 +27,8 @@ const useStyles = makeStyles(theme => ({
},
}));

const PendingOrders: FC<Props> = ({ orders = [], customers = {} }) => {
const PendingOrders = (props: Props) => {
const { orders = [], customers = {} } = props;
const classes = useStyles();
const translate = useTranslate();
return (
Expand Down
3 changes: 1 addition & 2 deletions examples/demo/src/dashboard/PendingReviews.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { FC } from 'react';
import {
Avatar,
Box,
Expand All @@ -24,7 +23,7 @@ interface Props {
nb?: number;
}

const PendingReviews: FC<Props> = ({ reviews = [], customers = {}, nb }) => {
const PendingReviews = ({ reviews = [], customers = {}, nb }: Props) => {
const classes = useStyles();
const translate = useTranslate();
return (
Expand Down
3 changes: 1 addition & 2 deletions examples/demo/src/dashboard/Welcome.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { FC } from 'react';
import { Box, Card, CardActions, Button, Typography } from '@material-ui/core';
import HomeIcon from '@material-ui/icons/Home';
import CodeIcon from '@material-ui/icons/Code';
Expand Down Expand Up @@ -37,7 +36,7 @@ const useStyles = makeStyles(theme => ({
},
}));

const Welcome: FC = () => {
const Welcome = () => {
const translate = useTranslate();
const classes = useStyles();
return (
Expand Down
3 changes: 1 addition & 2 deletions examples/demo/src/invoices/InvoiceList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { FC } from 'react';
import {
List,
ListProps,
Expand Down Expand Up @@ -30,7 +29,7 @@ const useStyles = makeStyles(theme => ({
},
}));

const InvoiceList: FC<ListProps> = props => {
const InvoiceList = (props: ListProps) => {
const classes = useStyles();
return (
<List
Expand Down
3 changes: 1 addition & 2 deletions examples/demo/src/invoices/InvoiceShow.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { FC } from 'react';
import Card from '@material-ui/core/Card';
import CardContent from '@material-ui/core/CardContent';
import Grid from '@material-ui/core/Grid';
Expand All @@ -15,7 +14,7 @@ import {
import Basket from '../orders/Basket';
import { Customer, Invoice } from '../types';

const CustomerField: FC<FieldProps<Customer>> = ({ record }) =>
const CustomerField = ({ record }: FieldProps<Customer>) =>
record ? (
<Typography>
{record.first_name} {record.last_name}
Expand Down
13 changes: 4 additions & 9 deletions examples/demo/src/layout/SubMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { FC, Fragment, ReactElement } from 'react';
import { Fragment, ReactElement, ReactNode } from 'react';
import { useSelector } from 'react-redux';
import {
List,
Expand Down Expand Up @@ -35,16 +35,11 @@ interface Props {
icon: ReactElement;
isOpen: boolean;
name: string;
children: ReactNode;
}

const SubMenu: FC<Props> = ({
handleToggle,
isOpen,
name,
icon,
children,
dense,
}) => {
const SubMenu = (props: Props) => {
const { handleToggle, isOpen, name, icon, children, dense } = props;
const translate = useTranslate();
const classes = useStyles();
const sidebarIsOpen = useSelector<ReduxState, boolean>(
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/src/orders/Basket.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { FC } from 'react';
import {
Table,
TableBody,
Expand All @@ -16,7 +15,8 @@ const useStyles = makeStyles({
rightAlignedCell: { textAlign: 'right' },
});

const Basket: FC<FieldProps<Order>> = ({ record }) => {
const Basket = (props: FieldProps<Order>) => {
const { record } = props;
const classes = useStyles();
const translate = useTranslate();

Expand Down
4 changes: 2 additions & 2 deletions examples/demo/src/orders/MobileGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// in src/comments.js
import * as React from 'react';
import { FC } from 'react';
import { Card, CardHeader, CardContent } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import {
Expand Down Expand Up @@ -45,7 +44,8 @@ interface MobileGridProps {
basePath?: string;
}

const MobileGrid: FC<MobileGridProps> = ({ ids, data, basePath }) => {
const MobileGrid = (props: MobileGridProps) => {
const { ids, data, basePath } = props;
const translate = useTranslate();
const classes = useListStyles();

Expand Down
5 changes: 2 additions & 3 deletions examples/demo/src/orders/OrderEdit.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { FC } from 'react';
import {
BooleanInput,
DateField,
Expand Down Expand Up @@ -32,7 +31,7 @@ interface OrderTitleProps {
record?: Order;
}

const OrderTitle: FC<OrderTitleProps> = ({ record }) => {
const OrderTitle = ({ record }: OrderTitleProps) => {
const translate = useTranslate();
return record ? (
<span>
Expand Down Expand Up @@ -228,7 +227,7 @@ const OrderForm = (props: any) => {
/>
);
};
const OrderEdit: FC<EditProps> = props => {
const OrderEdit = (props: EditProps) => {
const classes = useEditStyles();
return (
<Edit
Expand Down
6 changes: 3 additions & 3 deletions examples/demo/src/orders/OrderList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { FC, Fragment, useCallback, useEffect, useState } from 'react';
import { Fragment, useCallback, useEffect, useState } from 'react';
import {
AutocompleteInput,
BooleanField,
Expand Down Expand Up @@ -87,7 +87,7 @@ const useGetTotals = (filterValues: any) => {
};
};

const TabbedDatagrid: FC<TabbedDatagridProps> = props => {
const TabbedDatagrid = (props: TabbedDatagridProps) => {
const listContext = useListContext();
const { ids, filterValues, setFilters, displayedFilters } = listContext;
const classes = useDatagridStyles();
Expand Down Expand Up @@ -259,7 +259,7 @@ const TabbedDatagrid: FC<TabbedDatagridProps> = props => {
);
};

const OrderList: FC<ListProps> = props => (
const OrderList = (props: ListProps) => (
<List
{...props}
filterDefaultValues={{ status: 'ordered' }}
Expand Down
4 changes: 2 additions & 2 deletions examples/demo/src/orders/Totals.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { FC } from 'react';
import classnames from 'classnames';
import { Table, TableBody, TableCell, TableRow } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
Expand All @@ -13,7 +12,8 @@ const useStyles = makeStyles({
boldCell: { fontWeight: 'bold' },
});

const Totals: FC<FieldProps<Order>> = ({ record }: { record?: Order }) => {
const Totals = (props: FieldProps<Order>) => {
const { record } = props;
const classes = useStyles();
const translate = useTranslate();

Expand Down
3 changes: 1 addition & 2 deletions examples/demo/src/products/Aside.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import { FC } from 'react';
import inflection from 'inflection';
import { Card, CardContent } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
Expand Down Expand Up @@ -28,7 +27,7 @@ const useStyles = makeStyles(theme => ({
},
}));

const Aside: FC = () => {
const Aside = () => {
const { data, ids } = useGetList<Category>(
'categories',
{ page: 1, perPage: 100 },
Expand Down
Loading