Skip to content
This repository was archived by the owner on Sep 21, 2019. It is now read-only.

Commit 05ef34a

Browse files
committed
Rename React.SFC to React.FC
1 parent d870fd9 commit 05ef34a

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
@@ -58,7 +58,7 @@
5858
"@types/lodash": "^4.14.109",
5959
"@types/node": "^12.7.5",
6060
"@types/prettier": "^1.18.2",
61-
"@types/react": "^16.3.14",
61+
"@types/react": "^16.9.11",
6262
"dedent": "^0.7.0",
6363
"husky": "^3.0.5",
6464
"jest": "^24.9.0",

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
@@ -426,10 +426,17 @@
426426
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-1.18.2.tgz#069e7d132024d436fd1f5771f6932426a695f230"
427427
integrity sha512-2JBasa5Qaj81Qsp/dxX2Njy+MdKC767WytHUDsRM7TYEfQvKPxsnGpnCBlBS1i2Aiv1YwCpmKSbQ6O6v8TpiKg==
428428

429-
"@types/react@^16.3.14":
430-
version "16.3.14"
431-
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.3.14.tgz#f90ac6834de172e13ecca430dcb6814744225d36"
429+
"@types/prop-types@*":
430+
version "15.7.2"
431+
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.2.tgz#0e58ae66773d7fd7c372a493aff740878ec9ceaa"
432+
integrity sha512-f8JzJNWVhKtc9dg/dyDNfliTKNOJSLa7Oht/ElZdF/UbMUmAH3rLmAk3ODNjw0mZajDEgatA03tRjB4+Dp/tzA==
433+
434+
"@types/react@^16.9.11":
435+
version "16.9.11"
436+
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.11.tgz#70e0b7ad79058a7842f25ccf2999807076ada120"
437+
integrity sha512-UBT4GZ3PokTXSWmdgC/GeCGEJXE5ofWyibCcecRLUVN2ZBpXQGVgQGtG2foS7CrTKFKlQVVswLvf7Js6XA/CVQ==
432438
dependencies:
439+
"@types/prop-types" "*"
433440
csstype "^2.2.0"
434441

435442
"@types/stack-utils@^1.0.1":

0 commit comments

Comments
 (0)