-
Notifications
You must be signed in to change notification settings - Fork 2
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
Provide hooks for context-like access #7
Comments
Yeah, I saw the What are your use cases for this? |
I have a preliminary version which can be installed Here is example usage The render props are now accessible via the There is simple & reusable Others can be defined easily: import { useFormContext } from "react-form-action/client";
function DebugValidationError() {
const { isInvalid, validationError } = useFormContext();
return isInvalid && JSON.stringify(validationError);
} |
I've refactored the Form from createForm, so its not coupled with the context. This is good for UI styling, for example when we want to display the progress around the form, etc. This is just a sketch, but the ActionForm eventually should be just Form. import { Action, ActionForm } from "react-form-action/client";
function SubscribeForm() {
return (
<Action action={subscribeAction} initialData={null}>
<ActionForm>
<input type="text" name="email" data-testid="email" />
<button type="submit" data-testid="submit" />
</ActionForm>
{/* Read action state outside of <form> (ActionForm) */
<ValidationError />
</Action>
);
} |
It would be great if the package isn't limited to renderProps but instead can let child component access state via hooks.
The text was updated successfully, but these errors were encountered: