preactjs / preact

⚛️ Fast 3kB React alternative with the same modern API. Components & Virtual DOM.
https://preactjs.com
MIT License
36.58k stars 1.95k forks source link

Signals don't work #3892

Closed alexamy closed 1 year ago

alexamy commented 1 year ago

Describe the bug When using latest Preact version (v10.12.1), signals aren't working.

To Reproduce I'm using static html page without bundler.

Steps to reproduce the behavior:

  1. Open sandbox
  2. Click '+' button

Expected behavior The count incrementing by 1 after '+' button press.

Actual behavior In case of signal the count stays at 0 after '+' button press. In case of useSignal page isn't rendered at all.

Solution Downgrade to Preact v10.11.3.

alexamy commented 1 year ago

First issue was opened in https://github.com/preactjs/signals/issues/303.

marvinhagemeister commented 1 year ago

Quoting the other issue:

This is neither an issue with Preact or with signals. The code is not updating because you're loading multiple copies of Preact in that sandbox which are not aware of each other. Hooks require singletons to work behind the scenes (same in React) which doesn't play well with multiple copies of the framework being present.

Resolved in https://github.com/preactjs/signals/issues/303