First, thank you for showing me the Required type! I had no idea that existed. Makes a lot more sense than doing it manually with my own custom partial.
Second, I do like your approach. The only thing I find lacking in it, is the need to manually chunk those values into an args object (assuming you want them in a single object - like I do). But that's not really a huge objection, is it? Hmm...
From looking at your example, one of the problems with my prior approaches was probably that I wasn't consistently leveraging React.FC<>. From many of the examples I've been looking at online, it's not at all clear that this should be used whenever creating a functional React component - but I'm starting to think that's the case.
The nice thing about the React.FC is that it defines the return type of your function and it add children?: React.ReactNode to your props so no need to handle that prop yourself
First, thank you for showing me the Required type! I had no idea that existed. Makes a lot more sense than doing it manually with my own custom partial.
Second, I do like your approach. The only thing I find lacking in it, is the need to manually chunk those values into an
args
object (assuming you want them in a single object - like I do). But that's not really a huge objection, is it? Hmm...From looking at your example, one of the problems with my prior approaches was probably that I wasn't consistently leveraging
React.FC<>
. From many of the examples I've been looking at online, it's not at all clear that this should be used whenever creating a functional React component - but I'm starting to think that's the case.Very cool - thanks!!
Your welcome
The nice thing about the React.FC is that it defines the return type of your function and it add
children?: React.ReactNode
to your props so no need to handle that prop yourselfOIC. I think I had kinda stumbled into a different way to handle that. Cuz in my (final) example, my interface is defined as:
But I think I like the
React.FC
way better.