Skip to content

Commit bd6457d

Browse files
authored
add detail/summary wrapper
1 parent 4069bcd commit bd6457d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ Or you can use the provided generic type for functional components:
107107
const App: React.SFC<{ message: string }> = ({ message }) => <div>{message}</div>;
108108
```
109109

110-
Quite frankly I prefer the former pattern as it's shorter. However, if you need to use `children` property inside the function body, in the former case it has to be added explicitly. `SFC<T>` already includes the correctly typed `children` property which then doesn't have to become part of your type.
110+
<details>
111+
112+
<summary><b>Discussion</b></summary>
113+
114+
The former pattern is shorter, so why would people use `React.SFC` at all? If you need to use `children` property inside the function body, in the former case it has to be added explicitly. `SFC<T>` already includes the correctly typed `children` property which then doesn't have to become part of your type.
111115

112116
```tsx
113117
const Title: React.SFC<{ title: string }> = ({ children, title }) => (
@@ -117,6 +121,8 @@ const Title: React.SFC<{ title: string }> = ({ children, title }) => (
117121

118122
[Something to add? File an issue](https://github.com/sw-yx/react-typescript-cheatsheet/issues/new).
119123

124+
</details>
125+
120126
## Stateful Class-based Components
121127

122128
Within Typescript, `React.Component` is a generic type (aka `React.Component<PropType, StateType>`), so you actually want to provide it with prop and (optionally) state types:

0 commit comments

Comments
 (0)