This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-14
Channels
- # arachne (5)
- # architecture (2)
- # bangalore-clj (7)
- # beginners (96)
- # boot (34)
- # braveandtrue (1)
- # cider (12)
- # cljs-dev (38)
- # cljsrn (59)
- # clojure (326)
- # clojure-dev (35)
- # clojure-greece (1)
- # clojure-italy (6)
- # clojure-russia (47)
- # clojure-spec (16)
- # clojure-uk (25)
- # clojurescript (136)
- # core-async (18)
- # cursive (18)
- # datascript (2)
- # datomic (28)
- # dirac (6)
- # emacs (4)
- # garden (3)
- # hoplon (28)
- # instaparse (1)
- # jobs (4)
- # juxt (1)
- # lein-figwheel (10)
- # liberator (1)
- # mount (3)
- # off-topic (39)
- # om (16)
- # om-next (1)
- # onyx (15)
- # pedestal (9)
- # proton (1)
- # random (1)
- # re-frame (48)
- # reagent (8)
- # ring-swagger (4)
- # rum (3)
- # specter (5)
- # sql (3)
- # unrepl (273)
- # untangled (27)
- # vim (4)
- # yada (7)
I have an issue with Reagent and render-to-static-markup + a jquery plugin.
The component renders an input element which will be used by selectize. Selectize has a custom render function that uses render-to-static-markup.
React gives the following warning:
Warning: Exception thrown by hook while handling onSetChildren: Invariant Violation: Item must have been set
We initialize selectize on component-did-mount
:
(reagent/create-class
{:component-did-mount (fn [this]
(selectize! this))
:component-will-unmount #(.destroy (get-selectize))
:render (fn []
[:input {:id id}])})
I think it has something to do with batching. When I write (js/setTimeout #(selectize! this) 100)
it doesn’t give the warning
Also, when I don’t use render-to-static-markup but manually craft the HTML it works fine
not sure, since I hardly know myself why it’s working, but maybe you need to add the function to get the dom nod, (r/dom-node this). this works to add a touch event handler to a canvas: ` :component-did-mount (fn [this] ;; Use a go block so that the canvas exists before we attach the sketch ;; to it. (Needed on initial render; not on re-render.) (a/go (let [canvas-size (get-canvas-size) sketch-args* {:host "reframe-canvas" :size (first canvas-size) :draw #(draw-function (second canvas-size))}] (reset! saved-sketch-atom (apply q/sketch (apply concat sketch-args*)))) (let [mc (new js/Hammer.Manager (r/dom-node this))] (js-invoke mc "add" (new js/Hammer.Pan #js{"direction" js/Hammer.DIRECTION_ALL "threshold" 0})) (js-invoke mc "on" "pan" #(let [direction (.-direction %)] (cond (= direction 8) (dispatch [:change-direction [0 -1]]) (= direction 16) (dispatch [:change-direction [0 1]]) (= direction 4) (dispatch [:change-direction [1 0]]) (= direction 2) (dispatch [:change-direction [-1 0]]) ))) (reset! hammer-manager mc))))`
yeah, that wasn’t the issue. I think it has something to do with https://github.com/facebook/react/issues/8487