Skip to content

`preUpdate` and `postUpdate` callback hooks

Compare
Choose a tag to compare
@tdumitrescu tdumitrescu released this 18 Mar 05:18
· 387 commits to master since this release

This obviates the need to override the Component update() method in order to run code on every state update (for instance for logging state changes). Overriding update() potentially required explicit overrides for every component in the tree, whereas the hooks work gracefully with cascading updates. Example usage:

get config() {
  return {
    // ...
    hooks: {
      postUpdate: () => localStorage.setItem(`latestFoo`, this.state.foo),
    },
  };
}