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

React 19 Support? #4613

Open
abubakriz opened this issue Dec 19, 2024 · 11 comments
Open

React 19 Support? #4613

abubakriz opened this issue Dec 19, 2024 · 11 comments

Comments

@abubakriz
Copy link

Certain features from React 19 like useActionState and more currently do not work and therefore it is impossible to alias a react 19 project to preact

@JoviDeCroock
Copy link
Member

JoviDeCroock commented Dec 19, 2024

That depends on whether or not you use these API's, what particular use case are you seeking to fill with useActionState that is outside of server-components/...? React 19 hasn't been out for long and we are still in conversations about the merit of some of these hooks

@bcomnes
Copy link

bcomnes commented Dec 19, 2024

Are function refs with cleanup supported in preact?

@rschristian
Copy link
Member

Yes, that landed in #4436

@abubakriz
Copy link
Author

abubakriz commented Dec 22, 2024

That depends on whether or not you use these API's, what particular use case are you seeking to fill with useActionState that is outside of server-components/...? React 19 hasn't been out for long and we are still in conversations about the merit of some of these hooks

useActionState is particulary useful, it eliminates a lot of boilerplate when it comes to form submission. It's true that you can do everything it does with the already existing hooks, but it's a lot cleaner IMO, and i've dropped libraries like react hook form thanks to it, (which also reduced my bundle size lol)

But most importantly, to me, preact has always been a tool that I can use as an alias for react to reduce my bundle size and improve my web app's experience, it would be a shame if that were not the case anymore

@JoviDeCroock
Copy link
Member

I 100% understand that it's a convenient utility, and you are free to PR it if you like 😅 I haven't been able to deeply look into the nuances just yet.

@laurentpayot

This comment has been minimized.

@davidbonnet
Copy link

Mentioned in #2621 is the support for the ref prop, which React 19 now does. Any insights on whether work has started on this to avoid duplicate contributions?

@rschristian
Copy link
Member

See #4617

@mayank99
Copy link

It might be difficult for Preact to fully support a lot of these new features, because actions build upon transitions. In theory, useActionState can be shimmed using useTransition. However, I was looking at the current implementation of useTransition in preact/compat and it always returns false for the pending state, which limits its usefulness.

export function useTransition() {
return [false, startTransition];
}

useFormStatus would have a similar problem as well.

A good first step might be to start by supporting form action functions (i.e. <form action={() => {}}> and <button formAction={() => {}}>). These would effectively just call preventDefault in the form's onSubmit event handler.

This was referenced Dec 29, 2024
@davidbonnet
Copy link

See #4617

Ah it's added to the v11 branch. Shall we consider v10 as well?

@rschristian
Copy link
Member

Can't be done w/out a breaking change, however, #4623 added a new preact/compat/react-19 entry which you can use in your aliases to get access to it.

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

No branches or pull requests

7 participants