Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we reverse it? #24

Open
httpete opened this issue Aug 16, 2022 · 1 comment
Open

Can we reverse it? #24

httpete opened this issue Aug 16, 2022 · 1 comment

Comments

@httpete
Copy link

httpete commented Aug 16, 2022

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?

@gndelia
Copy link
Owner

gndelia commented Aug 16, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants