Signals are reactive. They keep track of the subscriptions and notify subscribers when state has changed. Calling the getter creates a subscription, telling the signal of the location that requires the value.
Signals vs useState()
useSignal() => getter + setter
useState() => value + setter
useState() is not reactive. React does not know of the location that requires the value, therefore must re-renders the whole component when calling the setter.
Signals
(Reference)
Signals are reactive. They keep track of the subscriptions and notify subscribers when state has changed. Calling the getter creates a subscription, telling the signal of the location that requires the value.
Signals vs useState()
useSignal()=> getter + setteruseState()=> value + setteruseState()is not reactive. React does not know of the location that requires the value, therefore must re-renders the whole component when calling the setter.(Reference)
Signals in frameworks
SolidJS
Qwik
Preact
Vue
Angular
Angular has announced some prototyping work around adding signals as a reactive primitive in Angular.