JavaScript preactjs.com

The Preact team introduces Signals  ↦

The Preact team dropped a new state management solution on us:

Signals are a way of expressing state that ensure apps stay fast regardless of how complex they get. Signals are based on reactive principles and provide excellent developer ergonomics, with a unique implementation optimized for Virtual DOM.

Adding Signals to your Preact app only adds 1.6kB to your bundle size. So what’s the big idea?

The main idea behind signals is that instead of passing a value directly through the component tree, we pass a signal object containing the value (similar to a ref). When a signal’s value changes, the signal itself stays the same. As a result, signals can be updated without re-rendering the components they’ve been passed through, since components see the signal and not its value. This lets us skip all of the expensive work of rendering components and jump immediately to the specific components in the tree that actually access the signal’s value.


Discussion

Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00