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

fix: handle preact signals in array correctly #11834

Merged
merged 5 commits into from
Aug 28, 2024

Conversation

ph1p
Copy link
Contributor

@ph1p ph1p commented Aug 25, 2024

Changes

This will fix the serialization of preact signals, when they got passed as an array. It also works for objects.

Now it's possible to do something like this:

---
import { signal } from '@preact/signals';

const arrayWithSignals = [
  signal(0),
  signal(30),
  "simple string",
  "a number",
  signal("string signal")
]
---
<ArrayWithSignals count={arrayWithSignals} client:visible>
  <h1>Hello, from array!</h1>
</ArrayWithSignals>

closes #7864

Testing

Tests added.

Docs

Nothing should change for the user.

Before:

before.mp4

After:

after.mp4

Copy link

changeset-bot bot commented Aug 25, 2024

🦋 Changeset detected

Latest commit: 9ace408

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 pkg: preact Related to Preact (scope) pkg: integration Related to any renderer integration (scope) pkg: astro Related to the core `astro` package (scope) labels Aug 25, 2024
@ph1p ph1p force-pushed the fix/preact-signals branch 2 times, most recently from 8bcd683 to 3ca7f79 Compare August 25, 2024 12:36
@ph1p ph1p force-pushed the fix/preact-signals branch 2 times, most recently from 23bb882 to b5adf3f Compare August 25, 2024 12:42
@ph1p ph1p force-pushed the fix/preact-signals branch 2 times, most recently from b45154f to adb61ab Compare August 25, 2024 18:09
@ph1p ph1p force-pushed the fix/preact-signals branch from adb61ab to 2a582d1 Compare August 25, 2024 18:19
@ph1p ph1p force-pushed the fix/preact-signals branch from 6b5cb8c to 4c4c46e Compare August 28, 2024 10:13
@ematipico ematipico merged commit 5f2536b into withastro:main Aug 28, 2024
13 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope) pkg: preact Related to Preact (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Signals inside array/objects doesnt serialize correctly
2 participants