From cec455c0e42d7a3f582cd14cbbe36288bf2a1b92 Mon Sep 17 00:00:00 2001 From: ellieseastream <67265053+ellieseastream@users.noreply.github.com> Date: Wed, 1 Jul 2020 17:30:28 +0200 Subject: [PATCH] Update adr006-avoid-react-fc.md --- .../adr006-avoid-react-fc.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/docs/architecture-decisions/adr006-avoid-react-fc.md b/docs/architecture-decisions/adr006-avoid-react-fc.md index af8db8795d97d..89234c069733e 100644 --- a/docs/architecture-decisions/adr006-avoid-react-fc.md +++ b/docs/architecture-decisions/adr006-avoid-react-fc.md @@ -2,23 +2,22 @@ ## Context -Facebook has removed ```React.FC``` from their base template for a Typescript project. The reason for this was that it was found to be an unnecessary feature with next to no benefits in combination with a few downsides. +Facebook has removed `React.FC` from their base template for a Typescript project. The reason for this was that it was found to be an unnecessary feature with next to no benefits in combination with a few downsides. The main reasons were: - **children props** were implicitly added -- **Generic Type** lacked support +- **Generic Type** were not supported on children Read more about the removal in [this PR](https://github.com/facebook/create-react-app/pull/8177). ## Decision -To keep our codebase up to date, we have decided that React.FC and React.SFC should be avoided in our codebase when adding new code. +To keep our codebase up to date, we have decided that `React.FC` and `React.SFC` should be avoided in our codebase when adding new code. Here is an example: -```` +```ts /* Avoid this: */ type BadProps = { text: string; }; - const BadComponent: FC = ({ text, children }) => (
{text}
@@ -26,17 +25,16 @@ const BadComponent: FC = ({ text, children }) => (
) - /* Do this instead: */ -type GoodProps = { text: string; children?: React.ReactNode }; +type GoodProps = { text: string; children?: React.ReactNode; }; const GoodComponent = ({ text, children }: GoodProps) => (
{text}
{children}
) -```` +``` ## Consequences -We will gradually remove the current usage of React.FC and React.SFC from our codebase. +We will gradually remove the current usage of `React.FC` and `React.SFC` from our codebase.