Upgrade to Pro — share decks privately, control downloads, hide ads and more …

picodomでVDOMの理解を深める

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on.
Avatar for takanorip takanorip
January 25, 2018

 picodomでVDOMの理解を深める

Avatar for takanorip

takanorip

January 25, 2018
Tweet

More Decks by takanorip

Other Decks in Technology

Transcript

  1. 自己紹介 • 大木 尊紀(オオキ タカノリ) / @takanorip • 株式会社スマートドライブ •

    フロントエンドエンジニア • React、Vue、Polymer、Web制作全般 • Polymer Japan 翻訳チーム • 「イヌでもわかる Web Components」
 好評配信中 • 輝夜月かわいい
  2. 構成とか • picodomの構成 • h.js:h()の定義 / 29行 • patch.js:patch()を定義 /

    206行 • (index.jsは↑2つのファイルをimportしてるだけ)
  3. h("div", {id: 'app'}, [ h("h1", {class: 'title'}, 'Title'), h("button", {

    onclick: () => {hoge: 'fuga'} }, "+"), 'some text' ]);
  4. { name: "div", props: { id: "app" }, children: [

    { name: "h1", props: { class : "title" }, children: ["Title"] }, { name: "button", props: { onclick: () => {hoge: 'fuga'} }, children: ["+"] }, "some text" ] }
  5. import { h, patch } from picodom /** @jsx h

    */ let node function render(view, withState) { patch(node, (node = view(withState))) } function view(state) { return ( <div> <h1>{state}</h1> <input autofocus type="text" value={state} oninput={e => render(view, e.target.value)} /> </div> ) } render(view, "Hello!")