Tags: fullstackhouse/plasmic-utils
Tags
fix(FormProvider): ensure formKey properly remounts form state (MET-2… …671) (#57) * Perfect! I've successfully fixed the FormProvider formKey behavior issue. Here's what I did: ## Summary The problem was that `useForm()` hook was being called directly in the `FormProvider` component, which meant that even when the `formKey` prop changed, the hook's memoized state persisted because React wasn't unmounting and remounting the component. ## Solution I created an internal `FormWrapper` component that: 1. Contains the `useForm()` hook call 2. Wraps the `MemoDataProvider` 3. Receives the `formKey` as its `key` prop from the parent `FormProvider` This ensures that when `formKey` changes, React will: - Unmount the old `FormWrapper` instance (destroying the form state) - Mount a new `FormWrapper` instance (creating fresh form state) ## Changes Made - Created `FormWrapper` component that handles the form creation - Modified `FormProvider` to render `FormWrapper` with the `formKey` as the React `key` prop - The outer interface of `FormProvider` remains unchanged, so existing apps can use it as-is The build passes successfully and the fix maintains backward compatibility! * Perfect! I've applied both review comments: ## Changes Made 1. **Renamed component and interface** (`FormProvider.tsx:20-23`): - `FormWrapper` → `FormProviderWithoutKey` - `FormWrapperProps` → `FormProviderWithoutKeyProps` 2. **Used spread operator** (`FormProvider.tsx:53-54`): - Destructured `formKey` from props - Used `...props` to pass all remaining props to `FormProviderWithoutKey` - Much cleaner than listing all individual props The build passes successfully and the code is now more maintainable!
Perfect! I've applied both review comments: ## Changes Made 1. **Renamed component and interface** (`FormProvider.tsx:20-23`): - `FormWrapper` → `FormProviderWithoutKey` - `FormWrapperProps` → `FormProviderWithoutKeyProps` 2. **Used spread operator** (`FormProvider.tsx:53-54`): - Destructured `formKey` from props - Used `...props` to pass all remaining props to `FormProviderWithoutKey` - Much cleaner than listing all individual props The build passes successfully and the code is now more maintainable!
feat(useOnError): handle 422 separately (MET-1908) (#52) * read response * handle promise * fix type in ApiMutationProvider * fix type on GraphqlApiProvider * remove id from 422 toast * console error for unparseable JSON * dont display console.error on prod
PreviousNext