Skip to content

Instantly share code, notes, and snippets.

@developit
Created February 6, 2019 21:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save developit/8112d2568f58a6a44ada12ab518d935c to your computer and use it in GitHub Desktop.
Save developit/8112d2568f58a6a44ada12ab518d935c to your computer and use it in GitHub Desktop.
import { Component } from 'preact';
/** Example:
* componentWillUnmount(){ uncache(this) }
*/
export function uncache(component) {
setTimeout(() => {
component.__b = component.nextBase = null;
})
}
/** Use it just like Component, but it won't cache DOM trees. */
export class WeakComponent extends Component {
componentWillUnmount() {
setTimeout(() => {
this.__b = this.nextBase = null;
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment