Created
February 6, 2019 21:23
-
-
Save developit/8112d2568f58a6a44ada12ab518d935c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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