File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -121,16 +121,8 @@ const App = ({ message }: { message: string }) => <div>{message}</div>;
121
121
Or you can use the provided generic type for function components:
122
122
123
123
``` tsx
124
- // React.FC also works
125
- const App: React .FunctionComponent <{ message: string }> = ({ message }) => <div >{ message } </div >;
126
- ```
127
-
128
- If you want to use the ` function ` keyword instead of an arrow function, you can use this syntax (using a function expression, instead of declaration):
129
-
130
- ``` tsx
131
- const App: React .FunctionComponent <{ message: string }> = function App({ message }) {
132
- return < div {message }< / div > ;
133
- }
124
+ // React.FunctionComponent also works
125
+ const App: React .FC <{ message: string }> = ({ message }) => <div >{ message } </div >;
134
126
```
135
127
136
128
<details >
@@ -145,7 +137,13 @@ const Title: React.FunctionComponent<{ title: string }> = ({ children, title })
145
137
);
146
138
```
147
139
148
- [ Something to add? File an issue] ( https://github.com/sw-yx/react-typescript-cheatsheet/issues/new ) .
140
+ If you want to use the ` function ` keyword instead of an arrow function, you can use this syntax (using a function expression, instead of declaration):
141
+
142
+ ``` tsx
143
+ const App: React .FunctionComponent <{ message: string }> = function App({ message }) {
144
+ return < div {message }< / div > ;
145
+ }
146
+ ```
149
147
150
148
</details >
151
149
You can’t perform that action at this time.
0 commit comments