i was going to wait until tomorrow to ask this, but while i'm on here troubleshooting something...is there a best practice with Om.Next for querying the DOM after components mount? i.e. code you'd put inside componentDidMount
if using straight React? particularly, i need the context of canvas elements and it doesn't seem to be working if i created it and call (.getContext (.getElementById ...) ...)
in the same function, which makes sense. but i'm not sure i understand how the reconciler works well enough to know for sure
david, thx for the answer
sophiago: usually for canvas you can render the canvas element in render
and attach a ref to it: https://facebook.github.io/react/docs/refs-and-the-dom.html
hey, just saw your message - i don't follow this code, did it end up working?
i put together an example here: https://github.com/dvingo/om-storybook-example/blob/master/src/cljs_storybook/components.cljs
I don't see how the ctx in your example is getting passed down
i actually had a really full day so didn't get to work on this. your code made sense just from the snippet, but the difference is i want to have the context in the store since i'm drawing to it from regular cljs functions (i'm trying to refactor a project that currently uses a hardcoded canvas because i realized it made more sense to use several of them generated on the fly)
perhaps i should just call swap!
inside componentDidMount
? i figured i could maybe assoc it through however the defui
macro assocs the keys, but am not sure if that even works slash what the correct syntax would be to do it
hey, seems like the confusion is mainly around the om way of doing things. it will probably help a lot to go through the om tutorials. tony kay (of untangled) has a really helpful one: https://github.com/awkay/om-tutorial
Thanks, I'll look into it. I think I've been using Om in a kind of hacky way so far, especially since I usually want to integrate it into a larger library. Like in another version of this library I just call swap!
on the store with data for my one key and it creates new elements from a factory. It works, but surely can't be the ideal way of doing things and now that I'm trying something more complicated it's creating trouble.
then grab the ref in didmount or did update
Also, just a general clojurescript gotcha is the (-.javascriptstuff ... ... ...)
trying on master
currently see the following error
➜ om git:(master) lein cljsbuild once hello
Compiling ClojureScript...
Compiling "examples/hello/main.js" from ["src" "examples/hello/src"]...
Compiling "examples/hello/main.js" failed.
clojure.lang.ExceptionInfo: failed compiling file:examples/hello/out/cljs/pprint.cljs {:file #object[java.io.File 0x1bff5ad0 "examples/hello/out/cljs/pprint.cljs"]}
...
Caused by: clojure.lang.ExceptionInfo: Invalid :refer, macro cljs.pprint/deftype does not exist in file examples/hello/out/cljs/pprint.cljs {:tag :cljs/analysis-error}
it does not seem specific to Om, but wanted to check here first
@pedroteixeira any headway ?
no, but boot devcards
is working. i posted on #clojurescript about the 'deftype does not exist'
dvingo: hey, i remember meeting you at the NYC Clojure meetup! i'm unclear what you're suggesting here, though. i know how to do this using the React API, but am wondering how to reconcile that (sorry for the pun) with Om.Next. iow, would it be enough to just update props in one function in order to render the canvas and then grab the context in another (as opposed to doing it in one shot inside a do
block)?