Skip to content

Conversation

@joelstein
Copy link
Contributor

The React Inertia useForm() hook is typed to return any, but we can improve this by returning Form<Data>, similar to the React Vue plugin.

However, there's no types.ts file in the react-inertia package, though the file exists in the vue-inertia package.

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.

@taylorotwell
Copy link
Member

Drafting pending review from @timacdonald

@taylorotwell taylorotwell marked this pull request as draft December 11, 2024 16:02
@timacdonald timacdonald self-assigned this Dec 11, 2024
@joelstein
Copy link
Contributor Author

Would it be possible to review this soon? Many thanks.

@joelstein
Copy link
Contributor Author

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/inertia#1

@timacdonald
Copy link
Member

@joelstein, just a heads up that PR is to your personal repository and not the official Inertia project.

@timacdonald
Copy link
Member

I'll be taking a look at this one soon.

@joelstein
Copy link
Contributor Author

Good catch! 🤦‍♂️

Here you go: inertiajs/inertia#2166

@timacdonald timacdonald changed the title Typescript return type for React Inertia useForm() [0.5.x] Typescript return type for React Inertia useForm() Jan 12, 2025
@timacdonald
Copy link
Member

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.

@joelstein
Copy link
Contributor Author

Perfect, thanks!

@timacdonald timacdonald changed the title [0.5.x] Typescript return type for React Inertia useForm() [0.6.x] Typescript return type for React Inertia useForm() Feb 11, 2025
@timacdonald
Copy link
Member

@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.

@joelstein
Copy link
Contributor Author

Bless you, good sir!

@timacdonald timacdonald marked this pull request as ready for review February 17, 2025 21:59
@taylorotwell taylorotwell merged commit 53950c0 into laravel:main Feb 18, 2025
4 checks passed
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

Successfully merging this pull request may close these issues.

3 participants