Created
May 30, 2017 03:14
-
-
Save Sophia-Gold/7724df5d774a19a6187a55d78e0d25f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns cljs-storybook.components | |
| (:require | |
| [om.next :as om :refer-macros [defui]] | |
| [om.dom :as dom] | |
| cljsjs.react)) | |
| (defn assign-ref [this ref] | |
| (fn [el] | |
| (aset this ref el))) | |
| (defui CanvasExample | |
| Object | |
| (componentDidMount [this] | |
| (let [canvas (aget this "canvas") | |
| ctx (.getContext canvas "2d") | |
| _ (aset this "ctx" ctx)] | |
| (aset ctx "fillStyle" "green") | |
| (-> ctx | |
| (.fillRect 10 10 100 100)))) | |
| (render [this] | |
| (dom/canvas #js {:ref (assign-ref this "canvas")}))) | |
| (defui Hello | |
| Object | |
| (render [this] | |
| (let [{:keys [name]} (om/props this)] | |
| (dom/div nil (str " your name is: " name))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment