adl32x / parcel-mithril-jsx

Parcel bundler + Mithril JS + JSX
MIT License
7 stars 2 forks source link

Suggest a slightly larger component using m.mount #1

Open jdillworth opened 5 years ago

jdillworth commented 5 years ago

I followed your example but I was confused for about 1.5 hours when I copied your use of m.render without realizing that redraw would be disabled (I'm very new to Mithril).

In index.js I suggest you replace this:

m.render(root, <p>Hello world</p>)

With something like this (untested):

m.mount(root, { 
  count: 0,
  onclick() {
    this.count++;
  },
  view() {
    return (<p>
      Count: {this.count}
      <button onclick={() => this.onclick()} />
    </p>);
  }
});
adl32x commented 5 years ago

Hey, thanks for the suggestion and apologies for the confusion! It's true that the auto redraw functionality lies in .mount(..). I'll put a more concrete example to the repo.

jdillworth commented 5 years ago

Thanks again for posting this repo!