Created
January 31, 2020 06:53
-
-
Save dongsik-yoo/987607b8ba19ebabc03d5cf156ae458a 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 { render, ComponentChild } from 'preact'; | |
import renderToString from 'preact-render-to-string'; | |
export default abstract class Base { | |
private _container: Element; | |
private _base?: Element; | |
public constructor(container: Element) { | |
this._container = container; | |
} | |
protected abstract getComponent(): JSX.Element; | |
public render(): void { | |
this._base = render(this.getComponent(), this._container, this._base); | |
} | |
public renderToString(): string { | |
return renderToString.render(this.getComponent()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment