question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: React with Typescript => void / boolean is not assignable to type 'FC<{}'

See original GitHub issue
import 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

  1. Create new FC
  2. 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:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

35reactions
alexrilicommented, Apr 11, 2021

Were you able to solve this because I am currently having same issue

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.

0reactions
dexiouzcommented, Apr 11, 2021

Were you able to solve this because I am currently having same issue

I was having the same problem, in my case are the file extension. instead of using “.jsx” I was using “.ts” soon as I fix the file extension the problem was solved.

How, you were able to use “.jsx” on a typescript file? And it worked?

I misstype , I was trying to say “.tsx”

Alright that’s fine. Thanks for the heads up. I’ll give it a try when I reinitialise a new project.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found