Skip to content
Discussion options

You must be logged in to vote

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:

  • The text updates (Submit → Submitting...)
  • The button disables correctly
  • Styling from your library stays intact

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@wingkwong
Comment options

@ahmetturp
Comment options

Comment options

You must be logged in to vote
1 reply
@ahmetturp
Comment options

Answer selected by ahmetturp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants