Can we reverse it?
httpete opened this issue · comments
Interestingly, now that React 18 types have removed the implicit children problem, I want to go the other way, from a function with props typed as an object to React.FunctionalComponent.. How hard would that be?
Hi @httpete ! Thanks for creating this issue.
So to have a concrete example (sorry - I haven't touched react for a few months so I'm all out of React 18), what you propose is going from
type Props = { foo: string }
const Component = (props: Props) => {
/* code */
}
to something like
type Props = { foo: string }
const Component: React.FunctionalComponent<Props> = (props) => {
/* code */
}
?
If not, could you provide an example?.
Assuming it is something like this:
1- It shouldn't be that hard, though lots of scenarios have to be contemplated (See all the scenarios that now exist!). It should be similar, but the other way around 😄
2- Not sure if it conflicts with the name of the repo 🤔 but let's ignore that for now.
At this moment I don't think I can implement this, so a PR (or multiple ones) is very welcome.