Fork me on GitHub
#reagent
<
2019-04-11
>
mikerod00:04:22

Maybe the props are still =

lilactown02:04:50

logging (:tab @tab-content) showed it change

lilactown02:04:24

I could actually see the props data structure change in React DevTools. but React did not re-render the component

lilactown02:04:13

I can’t think of how two CLJS structures could be different but referentially the same

Dustin Getz02:04:26

Check the compiled JS

lilactown02:04:43

I’m not sure if reagent implements it’s own shouldComponentUpdate and that might be at fault?

Dustin Getz02:04:51

Is it an ratom or a reaction? In really complex apps I have seen amazing spooky action at a distance caused by a missing doall in completely unrelated parts of the application impacting reactions

lilactown02:04:18

just a ratom with a map {:tab "resources"}. gets swap!’d when a button is pressed

lilactown02:04:46

I’ll see if I can create a minimal repro

lilactown02:04:20

ooooooooo I have a hunch

lilactown02:04:34

(defn fragment
  [{:keys [id]}]
  (let [content-data (data/pull! :styx
                                 {:from "fragmentEdition" :id id}
                                 {:contentful/raw true})]
    (fn []
      (if-not (:loading @content-data)
        (render {:id id :content-data (:data @content-data)})
        [:div "Loading..."]))))
🙂

lilactown02:04:41

form-2 components strike again!

lilactown03:04:22

I think we've had a bug pop up a couple times a quarter related to form-2 components since we started using reagent

lilactown03:04:01

specifically, a dev doesn't repeat the props in the fn arguments. or doesn't remember to use a form-2 component

mikerod03:04:45

@lilactown yeah, your form-2 will bite you there

mikerod03:04:56

they are risky ones, have to be careful anytime you write one

mikerod03:04:18

and just for completeness to this question: > I’m not sure if reagent implements it’s own shouldComponentUpdate and that might be at fault? Reagent does implement shouldComponentUpdate for you, if you don’t (via a form-3 component). You can see it here: https://github.com/reagent-project/reagent/blob/v0.8.1/src/reagent/impl/component.cljs#L160 In a form-1 or 2 component, you wouldn’t have your own shouldComponentUpdate, so it’d be the (nil? f) branch of the cond.

orestis09:04:09

@lilactown Ohhh I thought about form-2 components when you first said this but thought it the obvious thing so I never said anything 😞 I was using reagent/with-let instead of form-2 components, since it avoids this situation entirely…

lilactown14:04:34

haha. never underestimate the importance of saying the obvious in programming 😛

lilactown14:04:17

it’s hard too because this is someone else’s code on my team, so I’m playing the game of telephone with ya’ll

urbanslug19:04:31

Hello, anyone know how I can make this work: <Sidebar.Pushable as={Segment}> What I have is:

(:require  [reagent.core :as r]
             [soda-ash.core :as sa])
...
  [sa/SidebarPushable {:as (r/as-element [sa/Segment])}]
but that gives me an error: "Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: <Segment />. Did you accidentally export a JSX literal instead of a component?"

urbanslug19:04:58

Getting rid of the :as seems to work [sa/SidebarPushable (r/as-element [sa/Segment])]