Bug: React with Typescript => void / boolean is not assignable to type 'FC<{}'
See original GitHub issueimport React from 'React';
const SomeComponent: React.FC = ({children}) => {}
^^^^^^^^^^^^^
Type '({ children }: { children?: ReactNode; }) => boolean' is not assignable to type 'FC<{}>'
React version: 16.12.0 Typescript version: 3.7.3 @types/react version: 16.9.19
Steps To Reproduce
- Create new FC
- Try to desctructure children
Link to code example:
https://codesandbox.io/s/objective-herschel-y0myn
The current behavior
Errors out on compile
The expected behavior
Should be able to destrcture children just find
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top Results From Across the Web
void' is not assignable to type 'FC<IPickWinnerProps>' in react ...
You forgot to return some component from PickWinnerIdle therefore your functional component returns "void".
Read more >type '() => void' is not assignable to type 'fc<{}>'. - You.com
Current behavior: Using react-hook-form with @ionic/react@5.4.4 I get and error when trying to register a ref with IonInput :.
Read more >Incorrect "Type void is not assignable to type () => void" warning
I've checked this code in TypeScript , which doesn't produce an error: // script.ts type ScriptEvent = () => void; const scriptEvent: ScriptEvent...
Read more >[Solved]-Typescript - string' is not assignable to type 'FC-Reactjs
import React from 'react' const MoneyAmount = (props: { amount: number }) => { return ( new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", ......
Read more >Type 'void' is not assignable to type in TypeScript | bobbyhadz
The "Type 'void' is not assignable to type" TypeScript error occurs when we forget to return a value from a function, so the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I was having the same problem, in my case are the file extension. instead of using “.tsx” I was using “.ts” soon as I fix the file extension the problem was solved.
Alright that’s fine. Thanks for the heads up. I’ll give it a try when I reinitialise a new project.