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

Typescript return type for React Inertia useForm() #110

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

joelstein
Copy link

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
Author

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

@joelstein
Copy link
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.

https://github.com/joelstein/inertia/pull/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
Author

Good catch! 🤦‍♂️

Here you go: inertiajs/inertia#2166

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