forked from backstage/backstage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added example of changing existing React.FC code
- Loading branch information
1 parent
9f475ba
commit b926b4e
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,28 @@ | ||
# ADR006: Avoid React.FC | ||
|
||
## 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. | ||
|
||
The main reasons were: | ||
- **children props** were implicitly added | ||
- **Generic Type** lacked support | ||
|
||
## Decision | ||
|
||
To keep our codebase up to date, we have decided that React.FC should be avoided in our codebase when adding new code. | ||
|
||
Here is an example: | ||
```` | ||
type MyType = { text: string } | ||
// avoid React.FC | ||
const ComponentWithReactFC = React.FC<MyType> = ({text} => <div>{text}</div>) | ||
// do this instead | ||
const ComponentWithoutReactFC = ({text} : MyType) => <div>{text}</div> | ||
```` | ||
|
||
## Consequences | ||
|
||
We will gradually remove the current usage of React.FC from our codebase. |