You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All TSX generator templates currently use React.FC<Props> for component declarations:
constHelloWorld: React.FC<HelloWorldProps>=(props)=>{constHelloServer: React.FC<HelloServerProps>=({ name ='World'})=>{constHelloWorldApp: FC<HelloWorldAppProps>=(props)=>{
This is consistent across the codebase (every TSX template follows it), but React.FC has been discouraged by parts of the React community for several years.
Historical argument (now resolved):React.FC used to implicitly include children in props, leading to unexpected behavior. This was fixed in @types/react v18 — React.FC no longer includes children.
Remaining arguments against React.FC:
Makes return type implicit (always ReactElement | null)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
All TSX generator templates currently use
React.FC<Props>for component declarations:This is consistent across the codebase (every TSX template follows it), but
React.FChas been discouraged by parts of the React community for several years.Historical argument (now resolved):
React.FCused to implicitly includechildrenin props, leading to unexpected behavior. This was fixed in@types/reactv18 —React.FCno longer includeschildren.Remaining arguments against
React.FC:ReactElement | null)Arguments for keeping
React.FC:Not urgent or blocking. The convention works fine as-is. Just flagging for future consideration when the team next touches TSX templates.
Found during PR #2284 code review.
References:
Beta Was this translation helpful? Give feedback.
All reactions