-
Notifications
You must be signed in to change notification settings - Fork 44
[0.6.x] Typescript return type for React Inertia useForm() #110
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
Conversation
|
Drafting pending review from @timacdonald |
|
Would it be possible to review this soon? Many thanks. |
|
I just realized that Inertia wasn't exporting the form props for React. I submitted a pull request to fix that, after which this pull request will work. |
|
@joelstein, just a heads up that PR is to your personal repository and not the official Inertia project. |
|
I'll be taking a look at this one soon. |
|
Good catch! 🤦♂️ Here you go: inertiajs/inertia#2166 |
|
I believe the required Inertia PR should be released this week. After that I'll start taking a closer look at this one and see if we can get it shipped. |
|
Perfect, thanks! |
|
@joelstein, quick update here: I've gotten this one up to date with the latest type changes across the project. Next I'll do a once over to make sure our types are consistent across implementations and then this one should be ready to go. |
|
Bless you, good sir! |
The React Inertia useForm() hook is typed to return
any, but we can improve this by returningForm<Data>, similar to the React Vue plugin.However, there's no types.ts file in the
react-inertiapackage, though the file exists in thevue-inertiapackage.https://github.com/laravel/precognition/tree/main/packages/react-inertia/src
https://github.com/laravel/precognition/tree/main/packages/vue-inertia/src
I copied the types.ts file from vue-inertia, modified it with the correct imports, and updated the useForm() return type.