Skip to content

Instantly share code, notes, and snippets.

@jide
jide / *tracked.md
Last active March 30, 2017 23:24 — forked from developit/*tracked.md

tracked (fork) npm

@tracked is a decorator for Preact that makes working with state values no different than properties on your component instance.

It's one 300 byte function that creates a getter/setter alias into state/setState() for a given key, with an optional initial value. The "magic" here is simply that it works as a property decorator rather than a function, so it appears to integrate directly into the language.

tracked has no dependencies and works with any component implementation that uses this.state and this.setState().

Installation