Skip to content

Conversation

@joelstein
Copy link
Contributor

It would be helpful if we could import the Form type so we can do things like this:

import {PrecognitionForm, useForm} from "laravel-precognition-react-inertia";

type MyForm = {
  name: string;
};

type ContextType = {
  form: PrecognitionForm<MyForm>;
};

const Context = createContext({} as ContextType);

function SomeComplextForm() {
  const form = useForm<MyForm>("post", route("users.store"), user);

  return <Context.Provider value={{form}}>...</Context.Provider>;
}

This pull request exports Form as PrecognitionForm.

@timacdonald timacdonald marked this pull request as draft February 21, 2025 21:23
@timacdonald
Copy link
Member

Converting to draft so I can take a look and also make sure we do this consistently across packages if we head down this road. Will check it out next week.

@timacdonald timacdonald self-assigned this Feb 21, 2025
@timacdonald
Copy link
Member

@joelstein, I've updated this one to export the form type across all framework flavours.

I renamed the export to Form. I figure the importing code can then name that to whatever is wanted within their own code?

Just felt like the naming should align with the useForm export. Happy with this one?

@timacdonald timacdonald changed the title Export the Form type [0.7.0] Export the Form type Feb 26, 2025
@timacdonald timacdonald changed the title [0.7.0] Export the Form type [0.7.x] Export the Form type Feb 26, 2025
@joelstein
Copy link
Contributor Author

Yep! That works great.

@timacdonald timacdonald marked this pull request as ready for review February 27, 2025 22:09
@taylorotwell taylorotwell merged commit 68f8b62 into laravel:main Feb 27, 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