Skip to content

Commit c5daa47

Browse files
committed
style(ts): stopped using FC type
1 parent 96f3cc0 commit c5daa47

File tree

329 files changed

+5061
-5057
lines changed

Some content is hidden

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

329 files changed

+5061
-5057
lines changed

packages/alert/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ render(
5252
`src/App.tsx`
5353

5454
```tsx
55-
import React, { FC } from "react";
55+
import React, { ReactElement } from "react";
5656
import { useAddMessage } from "@react-md/alert";
5757
import { Button } from "@react-md/button";
5858

59-
const App: FC = () => {
59+
function App(): ReactElement {
6060
const addMessage = useAddMessage();
6161

6262
return (
@@ -67,7 +67,7 @@ const App: FC = () => {
6767
Show Message
6868
</Button>
6969
);
70-
};
70+
}
7171

7272
export default App;
7373
```

packages/app-bar/src/__tests__/useInheritContext.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { MutableRefObject, FC } from "react";
1+
import React, { MutableRefObject, ReactElement, ReactNode } from "react";
22
import { renderHook } from "@testing-library/react-hooks";
33
import { render } from "@testing-library/react";
44

@@ -15,9 +15,11 @@ describe("useInheritContext", () => {
1515
current: undefined,
1616
};
1717

18-
const Context: FC = ({ children }) => (
19-
<InheritContext.Provider value>{children}</InheritContext.Provider>
20-
);
18+
function Context({ children }: { children: ReactNode }): ReactElement {
19+
return (
20+
<InheritContext.Provider value>{children}</InheritContext.Provider>
21+
);
22+
}
2123

2224
const Test1 = () => {
2325
result.current = useInheritContext(undefined);

packages/autocomplete/README.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ However, it is recommended to also provide a `label` and `placeholder` text to
3232
help the user understand this component.
3333

3434
```tsx
35-
import React, { FC } from "react";
35+
import React from "react";
3636
import { AutoComplete } from "@react-md/autocomplete";
3737

3838
const fruits = [
@@ -47,15 +47,15 @@ const fruits = [
4747
"Strawberry",
4848
];
4949

50-
const Example: FC = () => (
51-
<AutoComplete
52-
id="search-fruits"
53-
name="fruits"
54-
label="Fruits"
55-
placeholder="Kiwi..."
56-
data={fruits}
57-
/>
58-
);
59-
60-
export default Example;
50+
function Example() {
51+
return (
52+
<AutoComplete
53+
id="search-fruits"
54+
name="fruits"
55+
label="Fruits"
56+
placeholder="Kiwi..."
57+
data={fruits}
58+
/>
59+
);
60+
}
6161
```

packages/chip/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ and more customization information, but an example usage is shown below.
2323
## Usage
2424

2525
```tsx
26-
import React, { FC } from "react";
26+
import React, { ReactElement } from "react";
2727
import { Chip } from "@react-md/chip";
2828

29-
const Example: FC = () => <Chip id="example-chip-1">I'm a chip!</Chip>;
30-
31-
export default Example;
29+
export default function Example(): ReactElement {
30+
return <Chip id="example-chip-1">I'm a chip!</Chip>;
31+
}
3232
```

packages/dev-utils/src/sandbox/createSandbox.ts

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ function transformFileContents(
5757

5858
if (demoName) {
5959
transformed = transformed
60-
.replace(`${demoName}: FC`, "Demo: FC")
6160
.replace(`default ${demoName};`, "default Demo;")
6261
.replace(new RegExp(`<${demoName}(\\s+)`, "g"), "<Demo$1");
6362
}

packages/dialog/src/__tests__/useNestedDialogFixes.tsx

+18-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { FC, MutableRefObject } from "react";
1+
import React, { MutableRefObject } from "react";
22
import { render } from "@testing-library/react";
33
import { renderHook } from "@testing-library/react-hooks";
44

@@ -40,7 +40,7 @@ describe("useNestedDialogFixes", () => {
4040
>;
4141

4242
const firstResult: Result = { current: undefined };
43-
const First: FC = () => {
43+
function First() {
4444
firstResult.current = useNestedDialogFixes({
4545
id: "dialog-1",
4646
visible: true,
@@ -49,10 +49,10 @@ describe("useNestedDialogFixes", () => {
4949
});
5050

5151
return null;
52-
};
52+
}
5353

5454
const secondResult: Result = { current: undefined };
55-
const Second: FC = () => {
55+
function Second() {
5656
secondResult.current = useNestedDialogFixes({
5757
id: "dialog-2",
5858
visible: true,
@@ -61,14 +61,16 @@ describe("useNestedDialogFixes", () => {
6161
});
6262

6363
return null;
64-
};
64+
}
6565

66-
const Test = () => (
67-
<NestedDialogContextProvider>
68-
<First />
69-
<Second />
70-
</NestedDialogContextProvider>
71-
);
66+
function Test() {
67+
return (
68+
<NestedDialogContextProvider>
69+
<First />
70+
<Second />
71+
</NestedDialogContextProvider>
72+
);
73+
}
7274

7375
render(<Test />);
7476
expect(firstResult.current).toEqual({
@@ -87,7 +89,7 @@ describe("useNestedDialogFixes", () => {
8789
const warn = jest.spyOn(console, "warn");
8890
// hide warnings
8991
warn.mockImplementation(() => {});
90-
const Dialog: FC = () => {
92+
function Dialog() {
9193
useNestedDialogFixes({
9294
id: "dialog-id",
9395
visible: true,
@@ -96,15 +98,16 @@ describe("useNestedDialogFixes", () => {
9698
});
9799

98100
return null;
99-
};
100-
const Test: FC = () => {
101+
}
102+
103+
function Test() {
101104
return (
102105
<NestedDialogContextProvider>
103106
<Dialog />
104107
<Dialog />
105108
</NestedDialogContextProvider>
106109
);
107-
};
110+
}
108111

109112
const { unmount } = render(<Test />);
110113
unmount();
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { FC, ReactNode } from "react";
1+
import React, { ReactElement, ReactNode } from "react";
22
import {
33
AppBarAction as RMDAppBarAction,
44
AppBarActionProps,
@@ -10,7 +10,7 @@ interface Props extends AppBarActionProps {
1010
tooltip?: ReactNode;
1111
}
1212

13-
const AppBarAction: FC<Props> = ({
13+
export default function AppBarAction({
1414
id,
1515
tooltip,
1616
onMouseEnter,
@@ -21,19 +21,19 @@ const AppBarAction: FC<Props> = ({
2121
onKeyDown,
2222
children,
2323
...props
24-
}) => (
25-
<Tooltipped
26-
id={id}
27-
tooltip={tooltip}
28-
onMouseEnter={onMouseEnter}
29-
onMouseLeave={onMouseLeave}
30-
onTouchStart={onTouchStart}
31-
onTouchMove={onTouchMove}
32-
onFocus={onFocus}
33-
onKeyDown={onKeyDown}
34-
>
35-
<RMDAppBarAction {...props}>{children}</RMDAppBarAction>
36-
</Tooltipped>
37-
);
38-
39-
export default AppBarAction;
24+
}: Props): ReactElement {
25+
return (
26+
<Tooltipped
27+
id={id}
28+
tooltip={tooltip}
29+
onMouseEnter={onMouseEnter}
30+
onMouseLeave={onMouseLeave}
31+
onTouchStart={onTouchStart}
32+
onTouchMove={onTouchMove}
33+
onFocus={onFocus}
34+
onKeyDown={onKeyDown}
35+
>
36+
<RMDAppBarAction {...props}>{children}</RMDAppBarAction>
37+
</Tooltipped>
38+
);
39+
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { FC, ReactNode } from "react";
1+
import React, { ReactElement, ReactNode } from "react";
22
import { AppBarNav as RMDAppBarNav, AppBarNavProps } from "@react-md/app-bar";
33
import { Tooltipped } from "@react-md/tooltip";
44

@@ -7,7 +7,7 @@ interface Props extends AppBarNavProps {
77
tooltip?: ReactNode;
88
}
99

10-
const AppBarNav: FC<Props> = ({
10+
export default function AppBarNav({
1111
id,
1212
tooltip,
1313
onMouseEnter,
@@ -18,19 +18,19 @@ const AppBarNav: FC<Props> = ({
1818
onKeyDown,
1919
children,
2020
...props
21-
}) => (
22-
<Tooltipped
23-
id={id}
24-
tooltip={tooltip}
25-
onMouseEnter={onMouseEnter}
26-
onMouseLeave={onMouseLeave}
27-
onTouchStart={onTouchStart}
28-
onTouchMove={onTouchMove}
29-
onFocus={onFocus}
30-
onKeyDown={onKeyDown}
31-
>
32-
<RMDAppBarNav {...props}>{children}</RMDAppBarNav>
33-
</Tooltipped>
34-
);
35-
36-
export default AppBarNav;
21+
}: Props): ReactElement {
22+
return (
23+
<Tooltipped
24+
id={id}
25+
tooltip={tooltip}
26+
onMouseEnter={onMouseEnter}
27+
onMouseLeave={onMouseLeave}
28+
onTouchStart={onTouchStart}
29+
onTouchMove={onTouchMove}
30+
onFocus={onFocus}
31+
onKeyDown={onKeyDown}
32+
>
33+
<RMDAppBarNav {...props}>{children}</RMDAppBarNav>
34+
</Tooltipped>
35+
);
36+
}
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import React, { FC, HTMLAttributes } from "react";
1+
import React, { HTMLAttributes, ReactElement } from "react";
22
import cn from "classnames";
33
import { Text } from "@react-md/typography";
44

5-
const Blockquote: FC<HTMLAttributes<HTMLDivElement>> = ({
5+
export default function Blockquote({
66
className,
77
children,
88
...props
9-
}) => (
10-
<blockquote {...props} className={cn("blockquote", className)}>
11-
<Text>{children}</Text>
12-
</blockquote>
13-
);
14-
15-
export default Blockquote;
9+
}: HTMLAttributes<HTMLDivElement>): ReactElement {
10+
return (
11+
<blockquote {...props} className={cn("blockquote", className)}>
12+
<Text>{children}</Text>
13+
</blockquote>
14+
);
15+
}

packages/documentation/src/components/Blog/Post.tsx

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { FC, ReactNode } from "react";
1+
import React, { ReactElement, ReactNode } from "react";
22
import { Divider } from "@react-md/divider";
33
import { TextIconSpacing } from "@react-md/icon";
44
import { KeyboardArrowRightSVGIcon } from "@react-md/material-icons";
@@ -45,14 +45,14 @@ function resolveReadMore(readMore: string | null): string | null {
4545
return `/blog/${readMore}`;
4646
}
4747

48-
const Post: FC<PostProps> = ({
48+
export default function Post({
4949
title,
5050
date,
5151
readMore,
5252
summary,
5353
bullets,
5454
isLast,
55-
}) => {
55+
}: PostProps): ReactElement {
5656
const href = resolveReadMore(readMore);
5757

5858
return (
@@ -89,6 +89,4 @@ const Post: FC<PostProps> = ({
8989
{!isLast && <Divider />}
9090
</>
9191
);
92-
};
93-
94-
export default Post;
92+
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { FC, ReactNode } from "react";
1+
import React, { ReactElement, ReactNode } from "react";
22
import { Button as RMDButton, ButtonProps } from "@react-md/button";
33
import { Tooltipped } from "@react-md/tooltip";
44

@@ -7,7 +7,7 @@ interface Props extends ButtonProps {
77
tooltip?: ReactNode;
88
}
99

10-
const Button: FC<Props> = ({
10+
export default function Button({
1111
id,
1212
tooltip,
1313
onMouseEnter,
@@ -18,19 +18,19 @@ const Button: FC<Props> = ({
1818
onKeyDown,
1919
children,
2020
...props
21-
}) => (
22-
<Tooltipped
23-
id={id}
24-
tooltip={tooltip}
25-
onMouseEnter={onMouseEnter}
26-
onMouseLeave={onMouseLeave}
27-
onTouchStart={onTouchStart}
28-
onTouchMove={onTouchMove}
29-
onFocus={onFocus}
30-
onKeyDown={onKeyDown}
31-
>
32-
<RMDButton {...props}>{children}</RMDButton>
33-
</Tooltipped>
34-
);
35-
36-
export default Button;
21+
}: Props): ReactElement {
22+
return (
23+
<Tooltipped
24+
id={id}
25+
tooltip={tooltip}
26+
onMouseEnter={onMouseEnter}
27+
onMouseLeave={onMouseLeave}
28+
onTouchStart={onTouchStart}
29+
onTouchMove={onTouchMove}
30+
onFocus={onFocus}
31+
onKeyDown={onKeyDown}
32+
>
33+
<RMDButton {...props}>{children}</RMDButton>
34+
</Tooltipped>
35+
);
36+
}

0 commit comments

Comments
 (0)