Skip to content

Instantly share code, notes, and snippets.

@developit
Created April 28, 2016 19:40
Show Gist options
  • Select an option

  • Save developit/51d19ba78f3221370abe3aebb8152a18 to your computer and use it in GitHub Desktop.

Select an option

Save developit/51d19ba78f3221370abe3aebb8152a18 to your computer and use it in GitHub Desktop.
decko
import { Component } from 'preact';
import { bind } from 'decko';
class MarkdownEditor extends Component {
constructor() {
super()
this.state = { text: '' };
}
@bind
onEdit(text) {
this.setState({ text });
}
render(props, { text }) {
return (
<main>
<section>
<label>Markdown</label>
<hr />
<Editor onEdit={this.onEdit} />
</section>
<section>
<label>Preview</label>
<hr />
<Markdown text={text} />
</section>
</main>
);
}
}
import { Component } from 'preact';
import { bind } from 'decko';
class MarkdownEditor extends Component {
state = { text: '' };
onEdit = (text) => {
this.setState({ text });
};
render(props, { text }) {
return (
<main>
<section>
<label>Markdown</label>
<hr />
<Editor onEdit={this.onEdit} />
</section>
<section>
<label>Preview</label>
<hr />
<Markdown text={text} />
</section>
</main>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment