-
Problem DescriptionHi, I have the following button on my HeroUI When I submit the form, the button doesn't change to the "loading" variant and the text doesn't change to "Submitting...". If I use regular button tags, the Expected ResultI expect to use HeroUI's Thank you for your help! You can find the whole component below: CodesandboxYou can see the problem here. Open https://codesandbox.io/p/devbox/romantic-mayer-qm8dnr?workspaceId=ws_9sNiQuzj9FPgLFKd9X5nWr |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
Hello all, Do you have any suggestions to my problem? |
Beta Was this translation helpful? Give feedback.
-
|
I tried your CodeSandbox and the issue is the same I had. With wrapped, React doesn’t always re-render the children when useFormStatus().pending changes. A simple fix is to force a re-render by giving the button a key. It can even be something short or random: <Button type="submit" disabled={pending} key={pending ? 1 : 0}>
{pending ? "Submitting..." : "Submit"}
</Button>This makes React recreate the button whenever pending changes, so:
|
Beta Was this translation helpful? Give feedback.



I tried your CodeSandbox and the issue is the same I had. With wrapped, React doesn’t always re-render the children when useFormStatus().pending changes.
A simple fix is to force a re-render by giving the button a key. It can even be something short or random:
This makes React recreate the button whenever pending changes, so: