Fork me on GitHub
#reagent
<
2016-04-22
>
mikethompson00:04:10

(defn item
  [i]
  [:div "item"]        ;;  <------  added 
  #_(reagent/create-class    ;; <--   commented out via #_
    {:component-did-mount #(println "foo")
     :reagent-render
     (fn [i]
       [:div.item {:class (item-class i)}]
        [:div.attr (:retailer_name i)]]
       )}))

mikethompson00:04:02

Do see "item"? My guess is that you won't. Ie. there is nothing wrong with this component. The issue will be elsewhere

mikethompson00:04:49

But, if you do see "item", then yes, there's an issue with this use of reagent/create-class

jeremyraines00:04:13

commented out part doesnt work, the one below, with just the hiccup, does

jeremyraines00:04:08

one thing that might be relevant is that this is being only rendered by another component

jeremyraines00:04:02

maybe something about that render-coll helper? But yeah, that would still imply that components created in this style have to be handled differently, which doesn’t make sense. Everything I am seeing says these are two ways to create an identical component

mikethompson00:04:40

Instead of (component i) you need [component i]

jeremyraines00:04:14

that did it, thanks. Will read up on the usage differences

rohit09:04:36

@mikethompson: reading your stackoverflow answer on multimethods and reagent: so multimethods don't play well with Form-2 reagent components. They do seem to work with Form-1 reagent components. Is my understanding correct?

juliobarros14:04:12

Anyone have suggestions/examples on a good way to add basic charts (bar, line, etc) to a Reagent/Re-Frame app?

juliobarros15:04:43

Thanks @gadfly361 are you using Morris? Had heard of some folks using Vega and was wondering what all the cool kids liked 😄

gadfly36115:04:28

i haven't decided on a preferred library yet (never heard of vega, but will check it out now!). Curious what other people like to use

Stefan Roex17:04:14

Does anyone know about a Uncaught TypeError: Cannot read property '_currentElement' of null error? I get this error every time an error occurs in an component and try to interact with the application. Even if figwheel reloads the code without the error, the TypeError continues, forcing me to refresh the page.

gadfly36118:04:58

You might be calling a component that is nil, like [foo-component] where foo-component is nil

Stefan Roex18:04:10

Hmm, the error-ing component will probably return nil, but its still a bummer that it requires a page-refresh afterwards

Stefan Roex18:04:40

I’m creating a minimal app with the same error. Will post a link to github in a moment.

gadfly36119:04:45

I think we are on the same page, but no harm in extra clarification. I was referring to the var foo-component itself having a value of nil. It'd be like calling a component like this [nil "some text"] (which will throw an error) as opposed to this [:div "some text"]. So if foo-component is nil, then [foo-component "some text"] wont return nil, it will throw an error.

Stefan Roex19:04:44

I’m not sure that is what happens. I’ve created an example repository so you’re able to reproduce the error

gadfly36120:04:03

@stex, able to reproduce. Tried a few things: 1) moving your (r/render ...) inside a function that figwheel calls on reload, and 2) making sure sub-component1 is getting passed new params. Neither made a reliable difference. When I run into this, i do just refresh the page...

Stefan Roex20:04:41

@gadfly361: Thanks. But seems odd, doesn’t it? Breaks the whole fighwheel workflow for us at our company. We aren’t perfect and make mistakes during development. Havent heart anyone else about this.

gadfly36120:04:14

I think if you get a significant runtime error like that, figwheel gets in a funky state. My naive understanding of figwheel is that it pushes diffs. So since figwheel pushed something broken, even if what comes after it is good, the broken bit that was pushed before isn't successfully replaced and instead persists (at least to some degree). Could be entirely wrong tho lol

Stefan Roex20:04:42

Figwheel unmounts and mounts all components, so theoretically it could start with a clean slate after a reload. I’ll try a few things next week, if I’ll find anything I’ll post it here.

gadfly36120:04:45

hope you figure it out, good luck! simple_smile

Stefan Roex20:04:11

Translated the example to om, and seems to work without a problem.

rafd21:04:44

coming from om+ fighwheel recently, I also noticed that reagent+figwheel doesn't handle errors as gracefully (usually requiring a refresh)