
React's type system, when used with TypeScript, provides developers with a robust framework for building type-safe applications. Understanding the ...
For further actions, you may consider blocking this person and/or reporting abuse
Component that want to get children from type doesnt need to implicitly declare it.
Instead, use:
React.PropsWithChildren<T>
Hi, thanks for dropping by.
I think it's a choice/preference.
React.PropsWithChildren
can be used to mimic the old behavior ofReact.FC
, but sometimes explicitly defining thechildren
prop has been more useful to me, e.g. when you need to force it to be a required property, or slightly modify its type. I think there's good reasons why they decided to remove the implicitchildren
prop fromReact.FC
.Great post! 👏👏
Thanks! Hope it was helpful to you.
Spot on article! I have a cheat sheet similar to this to help me because sometimes I just can't remember how to include children as props :-D
I guess at some point you’ll no longer need that cheat sheet anymore 😛.
Great post!
Keep going sir <3
Thanks! Please look forward to the next article.
Nice article ! Just the explanation of ElementType I needed
Great article
Good article, many times I like to use 'React.FC' to declare components, but I'm not sure why