Fork me on GitHub
#reagent
<
2017-02-24
>
joshkh00:02:21

i have a component that when mounted does some set up with the underling element via dom-node, but when figwheel reloads i get the following error which breaks the page until i manually reload. any ideas? Uncaught Error: findDOMNode was called on an unmounted component.

joshkh00:02:20

(i found a related github issue but it didn't get me very far)

joshkh00:02:37

(https://github.com/facebook/react/issues/4233, so maybe not a reagent specific issue)

pesterhazy00:02:07

@rodeorockstar which lifecycle method are you calling dom-node in?

joshkh00:02:16

component-did-mount

joshkh00:02:34

when the component mounts i'm intending to apply some css to scale it

pesterhazy00:02:56

hard to say without seeing the code

pesterhazy00:02:13

in any event I'd use a ref callback instead

pesterhazy00:02:19

it's made for the job

joshkh00:02:31

mind if i DM you? might be slightly work related!

pesterhazy00:02:41

findDOMNode is sorta kinda deprecated

joshkh00:02:15

wow i had no idea about the :ref property, and i think that'll solve my exact use case!

pesterhazy01:02:11

remember the callback gets called both on mount (with the node as arg) and on unmount (with nil as arg)

pesterhazy01:02:30

so usually you end up using (when node ...)

joshkh01:02:06

are you a reagent developer?

pesterhazy01:02:46

no but I've used reagent for a while now

pesterhazy01:02:52

I really dig it 🙂

joshkh01:02:31

absolutely. my first encounter with react was via reagent but i recently had to code a project in vanilla-ish react and it was painful. coffeescript + react.dom made it slightly more bearable but it pales in comparison!

joshkh01:02:24

on a side note, in your blog post, should :ref (function [el]...) read :ref (fn [el]...)?

pesterhazy01:02:31

thanks, fixed (once caches are invalidated)

joshkh01:02:37

cool! didn't mean to sound pedantic, just making sure i wasn't disregarding some secret reagent/function included in a :use somewhere 🙂

tomaas12:02:11

if I wrap map-indexed as the warning suggests, the warning is not thrown anymore. Anyway, I'd like to understand why it thrown after reseting the vector atom and how I could I avoid without wrapping in doall

pesterhazy12:02:05

personally I think - lazy seqs in reagent are an anti-feature. Use explicit (into [:div] (map ...)) instead - using meta-data to supply keys is an anti-feature. Use [:div {:key n}] explicitly instead

pesterhazy12:02:42

essentially, explicit is better than implicit

tomaas13:02:31

thanks again @pesterhazy 🙂

borkdude16:02:02

if I’m now using cljsjs to use React Virtualized, but I want to be able to step through that code (which the UMD build is not so suited for), what’s my best option?

borkdude16:02:46

I could add it using npm etc, or copy files, but I’m not sure how to make it work with my ClojureScript build

borkdude16:02:24

Maybe I can better ask in #clojurescript