Created
October 17, 2018 07:32
-
-
Save lukewatts/bb0389ff9660e736706811bd6e055a6c to your computer and use it in GitHub Desktop.
Medium Article - Use JSX with any MV* framework - Code Snippets - 13 - Test Component
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 dom from 'jsx-render'; | |
class Component | |
{ | |
view(el) | |
{ | |
el.appendChild(this.render()); | |
} | |
render() | |
{ | |
throw new Error('Classes which extend Component must implement a render() method which returns JSX, VirtualDOM or HTML!') | |
} | |
} | |
class Test extends Component | |
{ | |
constructor() | |
{ | |
super(); | |
this.view(document.getElementById('app')); | |
} | |
render() | |
{ | |
return ( | |
dom('h1', {}, 'Test') | |
); | |
} | |
} | |
new Test; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment