Skip to content
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

Actions: React 19 progressive enhancement support #11071

Merged
merged 16 commits into from
May 22, 2024

Conversation

bholmesdev
Copy link
Contributor

@bholmesdev bholmesdev commented May 16, 2024

Changes

This adds the necessary metadata to progressively enhance actions in React 19. This covers the base action prop and useActionState(). See changesets for full details.

import { actions } from 'astro:actions';

function Like() {
  return (
    <form action={actions.like}>
      {/* auto-inserts hidden input for progressive enhancement */}
      <button type="submit">Like</button>
    </form>
  )
}

Testing

Add React 19 e2e fixture:

  • test progressive enhancement with nonhydrated component
  • test pending status with useFormStatus() for hydrated component

Docs

Not yet!

Copy link

changeset-bot bot commented May 16, 2024

🦋 Changeset detected

Latest commit: 54f7e35

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label May 16, 2024
@github-actions github-actions bot added the semver: minor Change triggers a `minor` release label May 17, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

…ment (#11074)

* feat(ex): Like with useActionState

* feat: useActionState progressive enhancement!

* feat: getActionState utility

* chore: revert actions-blog fixture experimentation

* fix: add back actions.ts export

* feat(test): Like with use action state test

* fix: stub form state client-side to avoid hydration error

* fix: bad .safe chaining

* fix: update actionState for client call

* fix: correctly resume form state client side

* refactor: unify and document reactServerActionResult

* feat(test): useActionState assertions

* feat(docs): explain my mess

* refactor: add experimental_ prefix

* refactor: move all react internals to integration

* chore: remove unused getIslandProps

* chore: remove unused imports

* chore: undo format changes

* refactor: get actionResult from middleware directly

* refactor: remove bad result type

* fix: like button disabled timeout

* chore: changeset

* refactor: remove request cloning
@github-actions github-actions bot added pkg: react Related to React (scope) pkg: integration Related to any renderer integration (scope) docs pr A PR that includes documentation for review labels May 21, 2024
@bholmesdev bholmesdev changed the title Actions: React 19 basic progressive enhancement support Actions: React 19 progressive enhancement support May 21, 2024
@bholmesdev bholmesdev added this to the 4.9.0 milestone May 21, 2024
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, Ben!

@ematipico ematipico merged commit 8ca7c73 into main May 22, 2024
14 checks passed
@ematipico ematipico deleted the feat/react-19-basic-actions branch May 22, 2024 12:24
@astrobot-houston astrobot-houston mentioned this pull request May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs pr A PR that includes documentation for review pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope) pkg: react Related to React (scope) semver: minor Change triggers a `minor` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants