Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggest a slightly larger component using m.mount #1

Open
jdillworth opened this issue Apr 1, 2019 · 2 comments
Open

Suggest a slightly larger component using m.mount #1

jdillworth opened this issue Apr 1, 2019 · 2 comments

Comments

@jdillworth
Copy link

jdillworth commented Apr 1, 2019

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>);
  }
});
@jdillworth jdillworth changed the title Suggest an slightly larger component and using m.mount Suggest a slightly larger component using m.mount Apr 1, 2019
@adl32x
Copy link
Owner

adl32x commented Apr 3, 2019

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
Copy link
Author

Thanks again for posting this repo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants