Fork me on GitHub
#reagent
<
2016-05-03
>
lewix02:05:57

Should reagent {:key } always be a number?

lewix03:05:14

i expected {:key element-of-a-map} to work but it does not

mikethompson04:05:05

@lewix: it should be something which can be turned into a unique string.

mikethompson04:05:23

unique among siblings

lewix11:05:04

@mikethompson: i tried {:key (str c)} unsuccessfully - and I saw id use before which is not a string

mikethompson11:05:02

@lewix: what was unsuccessful?

mikethompson11:05:59

And I didn't say it had to be a string. I said it had to be something that could be turned into a string.

mikethompson11:05:16

And that it was unique amoung siblings

nfisher14:05:17

Does anyone have an explanation for why reagent components move the cursor during deletion? From React docs as long as it’s re-rendering it should keep the cursor position. My input component looks as follows:

nfisher14:05:00

As I understand by having the ratom in the closure it should cause the re-render to execute (retaining the cursor position) or is my understanding incorrect?

lwhorton18:05:55

is it common practice to use doall when rendering list components, or is that a smell? consider something like

(defn- render-row [row]
  (doall (for [it row]
    ^{:key (:id it)}
    [:div {:class s/col}
     [render-item it]])))

(defn render-list []
  [:div 
   [:ul
      (map-indexed
        (fn [idx row]
          ^{:key idx}
          [:li (render-row row)]) rows)]]))

lwhorton18:05:42

I can’t get the render-row row to render something unless I force lazy eval with a doall.. so I suppose reagent doesn’t do any op that would cause the lazy to evaluate?

tom18:05:44

I was able to set up a reagent component using reactify-component and create-class such that :reagent-render sets up the component and checks the props map to set state. However any change of state get overwritten instantly by that initial props state. Is that just me not using the lifecycle functions properly?

madvas18:05:16

Hi Reagents! I added to cljs-react-material-ui full support for Reagent. Using Reagent with MaterialUI is now breeze 😉 https://github.com/madvas/cljs-react-material-ui

hugobessaa19:05:12

@lwhorton: it is ok. you can user mapv too.

fabrao19:05:19

Hello all, I´m trying re-frame and I implemented the views part like:

(defmulti paginas identity)
(defmethod paginas :pagina-login [] [vlogin/login])
(defmethod paginas :pagina-principal [] [:div "HAHAHA"])
(defmethod paginas :default [] [:div])

(defn mostrar-pagina [id-pagina]
  [paginas id-pagina])

(defn pagina []
  (let [pagina-ativa (re-frame/subscribe [:pagina-ativa])]
    (fn []
      [mostrar-pagina @pagina-ativa]))) 
That render page when I change :pagina-ativa. So, If I want to execute something like setting focus, what is the best way to do in re-frame?

hugobessaa19:05:13

@fabrao: this topic has great answers

fabrao22:05:18

@hugobessaa: it worked, thanks a lot

mikethompson23:05:55

@lwhorton: keys are useful when your list is quite dynamic, with items being added to, and removed from, the list quite often. But if the list is fairly static, then forget keys are just use into:

(defn render-list []
  [:div 
      (into [:ul]   (map  (fn [row] [:li (render-row row)]) rows))])