Introducing Preact Signals: a reactive state primitive that is fast by default. ✅ feels like using plain values 🥳 automatic updates when values change ⏱ updates DOM directly (fast!) 🥹 no dependencies arrays preactjs.com/blog/introduci…
What makes Signals unique is that state changes automatically update components and UI in the most efficient way possible. You don't have to write any code to opt into this - simply accessing a signal's value in a component will set everything up for you.
Signals are deeply integrated into Preact to provide the best possible performance and ergonomics. Since everything is automatic, you can learn Signals without worrying about the most common state management footguns.
Signals provide the benefits of fine-grained state updates regardless of whether state is global, passed via props or context, or local to a component. You can use them inside or outside of components, unlike hooks. They also work great alongside both hooks and class components.
For folks using React, there's a version of Signals for you too!
@_developit Nice, and very useful! Glad to see it's possible to use in React, not so many codebases we've worked on have switched to Preact yet.
@_developit How does it play with react state? does signal also update virtual DOM? I tried below code, its not working can you explain what is going wrong with this?