Closed chronark closed 8 months ago
I would like to raise a PR for this bug π
hey @chronark, I have noticed that form.formState.isSubmitting has been directly used without invoked or subscribed to.
` <Button variant={form.formState.isSubmitting ? "disabled" : "primary"} type="submit" disabled={form.formState.isSubmitting}
{form.formState.isSubmitting ?
: "Save"} `
official docs stats - formState is wrapped with a Proxy to improve render performance and skip extra logic if specific state is not subscribed to. Therefore make sure you invoke or read it before a render in order to enable the state update.
But I have also tried to destruct the formState from form to read isSubmitting before using as the state update but it didn't work.
const {formState:{isSubmitting}} = form
`<Button
variant={isSubmitting ? "disabled" : "primary"}
type="submit"
disabled={isSubmitting}
{isSubmitting?
: "Save"} `
We make use of react query's isLoading property from updateName mutation and It works.
` <Button variant={updateName.isLoading ? "disabled" : "primary"} type="submit" disabled={updateName.isLoading}
{updateName.isLoading ?
: "Save"} `
https://github.com/unkeyed/unkey/assets/100031493/33c3511e-25a6-407a-8a94-6aab82e2052d
Ah very nice, thanks for digging in, then let's use the mutation state π
hey @chronark , I have also created a PR, please do check it out !βΊοΈ
Preliminary Checks
Reproduction / Replay Link (Optional)
No response
Issue Summary
The "Save" button should show a loading spinner during the mutation
Steps to Reproduce
Expected behavior
It should display a loading spinner
Other information
No response
Screenshots
No response
Version info