Skip to content

Commit 4f0906d

Browse files
maurer2swyxio
andauthored
Add paragraph on VFC deprecation (#499)
Co-authored-by: swyx <shawnthe1@gmail.com>
1 parent bf54bf2 commit 4f0906d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

docs/basic/getting-started/function-components.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,12 @@ const Title: React.FunctionComponent<{ title: string }> = ({
5555
```
5656

5757
<details>
58-
<summary><b>Using <code>React.VoidFunctionComponent</code> or <code>React.VFC</code> instead</b></summary>
58+
<summary>(Deprecated)<b>Using <code>React.VoidFunctionComponent</code> or <code>React.VFC</code> instead</b></summary>
5959

60-
As of [@types/react 16.9.48](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/46643), you can also use `React.VoidFunctionComponent` or `React.VFC` type if you want to type `children` explicitly. This is an interim solution until `FunctionComponent` will accept no children by default (planned for `@types/react@^18.0.0`).
60+
In [@types/react 16.9.48](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/46643), the `React.VoidFunctionComponent` or `React.VFC` type was added for typing `children` explicitly.
61+
However, please be aware that `React.VFC` and `React.VoidFunctionComponent` were deprecated in React 18 (https://github.com/DefinitelyTyped/DefinitelyTyped/pull/59882), so this interim solution is no longer necessary or recommended in React 18+.
62+
63+
Please use regular function components or `React.VFC` instead.
6164

6265
```ts
6366
type Props = { foo: string };

0 commit comments

Comments
 (0)