Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit ee2c969

Browse files
committed
Rename React.SFC to React.FC
1 parent 3b91d88 commit ee2c969

File tree

12 files changed

+23
-18
lines changed

12 files changed

+23
-18
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"@types/lodash": "^4.14.109",
4949
"@types/node": "^10.1.2",
5050
"@types/prettier": "^1.12.2",
51-
"@types/react": "^16.3.14",
51+
"@types/react": "^16.9.2",
5252
"dedent": "^0.7.0",
5353
"husky": "^0.14.3",
5454
"jest": "^22.4.4",

src/transforms/react-stateless-function-make-props-transform.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export type Factory = ts.TransformerFactory<ts.SourceFile>;
2525
* message: string;
2626
* }
2727
*
28-
* const Hello: React.SFC<HelloProps> = ({ message }) => {
28+
* const Hello: React.FC<HelloProps> = ({ message }) => {
2929
* return <div>hello {message}</div>
3030
* }
3131
*
@@ -83,7 +83,7 @@ function visitReactStatelessComponent(
8383
const propTypeDeclaration = ts.createTypeAliasDeclaration([], [], propTypeName, [], propType);
8484
const propTypeRef = ts.createTypeReferenceNode(propTypeName, []);
8585

86-
let componentType = ts.createTypeReferenceNode(ts.createQualifiedName(ts.createIdentifier('React'), 'SFC'), [
86+
let componentType = ts.createTypeReferenceNode(ts.createQualifiedName(ts.createIdentifier('React'), 'FC'), [
8787
shouldMakePropTypeDeclaration ? propTypeRef : propType,
8888
]);
8989

test/collapse-intersection-interfaces-transform/repeated/output.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
type A = {
22
foo: string,
33
};
4-
54
type B = {
65
foo: string | number,
76
bar: number,
87
};
9-
108
type C = {
119
foo: string | number,
1210
bar: number,

test/end-to-end/multiple-components/output.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
type HelloProps = {
22
message?: string,
33
};
4-
const Hello: React.SFC<HelloProps> = ({ message }) => {
4+
const Hello: React.FC<HelloProps> = ({ message }) => {
55
return <div>hello {message}</div>;
66
};
77
type HeyProps = {
88
message?: string,
99
};
10-
const Hey: React.SFC<HeyProps> = ({ name }) => {
10+
const Hey: React.FC<HeyProps> = ({ name }) => {
1111
return <div>hey, {name}</div>;
1212
};
1313
type MyComponentState = {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
type HelloProps = {
22
message?: string,
33
};
4-
const Hello: React.SFC<HelloProps> = ({ message }) => {
4+
const Hello: React.FC<HelloProps> = ({ message }) => {
55
return <div>hello {message}</div>;
66
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
type HelloProps = {
22
message?: string,
33
};
4-
export const Hello: React.SFC<HelloProps> = ({ message }) => {
4+
export const Hello: React.FC<HelloProps> = ({ message }) => {
55
return <div>hello {message}</div>;
66
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const Hello: React.SFC<{}> = () => {
1+
const Hello: React.FC<{}> = () => {
22
return <div />;
33
};
44
Hello.propTypes = {};

test/react-stateless-function-make-props-transform/multiple-components/output.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
type HelloProps = {
22
message?: string,
33
};
4-
const Hello: React.SFC<HelloProps> = ({ message }) => {
4+
const Hello: React.FC<HelloProps> = ({ message }) => {
55
return <div>hello {message}</div>;
66
};
77
type HeyProps = {
88
name: string,
99
};
10-
const Hey: React.SFC<HeyProps> = ({ name }) => {
10+
const Hey: React.FC<HeyProps> = ({ name }) => {
1111
return <div>hey, {name}</div>;
1212
};
1313
Hey.propTypes = {

test/react-stateless-function-make-props-transform/stateless-arrow-function/output.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
type HelloProps = {
22
message?: string,
33
};
4-
const Hello: React.SFC<HelloProps> = ({ message }) => {
4+
const Hello: React.FC<HelloProps> = ({ message }) => {
55
return <div>hello {message}</div>;
66
};
77
Hello.propTypes = {

test/react-stateless-function-make-props-transform/stateless-function-many-props/output.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type MyComponentProps = {
3939
fontSize: number,
4040
},
4141
};
42-
const MyComponent: React.SFC<MyComponentProps> = () => {
42+
const MyComponent: React.FC<MyComponentProps> = () => {
4343
return <div />;
4444
};
4545
MyComponent.propTypes = {

test/react-stateless-function-make-props-transform/stateless-function/output.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
type HelloProps = {
22
message?: string,
33
};
4-
const Hello: React.SFC<HelloProps> = ({ message }) => {
4+
const Hello: React.FC<HelloProps> = ({ message }) => {
55
return <div>hello {message}</div>;
66
};
77
Hello.propTypes = {

yarn.lock

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,17 @@
6868
version "1.12.2"
6969
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-1.12.2.tgz#4a37f0aa8ed20366ada6fa7994b1c6dfe787fdd1"
7070

71-
"@types/react@^16.3.14":
72-
version "16.3.14"
73-
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.3.14.tgz#f90ac6834de172e13ecca430dcb6814744225d36"
71+
"@types/prop-types@*":
72+
version "15.7.2"
73+
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.2.tgz#0e58ae66773d7fd7c372a493aff740878ec9ceaa"
74+
integrity sha512-f8JzJNWVhKtc9dg/dyDNfliTKNOJSLa7Oht/ElZdF/UbMUmAH3rLmAk3ODNjw0mZajDEgatA03tRjB4+Dp/tzA==
75+
76+
"@types/react@^16.9.2":
77+
version "16.9.2"
78+
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.2.tgz#6d1765431a1ad1877979013906731aae373de268"
79+
integrity sha512-jYP2LWwlh+FTqGd9v7ynUKZzjj98T8x7Yclz479QdRhHfuW9yQ+0jjnD31eXSXutmBpppj5PYNLYLRfnZJvcfg==
7480
dependencies:
81+
"@types/prop-types" "*"
7582
csstype "^2.2.0"
7683

7784
abab@^1.0.4:

0 commit comments

Comments
 (0)