JSFiddle - React, Tailwind, and code Playground

Mithril counter

by dmitri14

HTML

<script src="https://cdn.rawgit.com/lhorie/mithril.js/rewrite/mithril.min.js"></script>
<div id="app"></div>

Babel + JSX

const Component = {
  oninit({ state }) {
    state.seconds = 0;
    state.count = () => {
      state.seconds++;
      m.redraw();
    };
    state.interval = setInterval(state.count, 1000);
  },
  onremove({ state }) {
    clearInterval(state.interval);
  },
  view({ state }) {
    return m('span', `Timer: ${state.seconds}`);
  }
};

const mountNode = document.getElementById('app');
m.mount(mountNode, Component);