Fork me on GitHub
#reagent
<
2016-11-15
>
yenda09:11:47

is it me or component-did-update only has access to the old props ?

reefersleep11:11:29

I'm trying to render an :option element with :home/room as the value, but only room is rendered in the UI. Is this because reagent resolves keywords with (name :home/room) whenever you try to use them as a visible value in the UI?

reefersleep12:11:18

seems to be the case for [:div :elmer/hey] too

reefersleep12:11:25

only hey is rendered

reefersleep12:11:39

so I guess this is part of reagent's render functionality

emil0r13:11:14

hi. anyone know how to stop input to lose focus due to a re-rendering when you’re adding new elements to the parent (which also holds the key)?

curlyfry15:11:21

Hi, Sometimes I feel a bit limited by the fact that Reagent requires :key props when a sequence is produced. In some cases it really seems like the nicest way of doing some things is to use the sequence library to create certain patterns. For example, consider a sequence of "breadcrumbs" separated by a (font-awesome) arrow: (interpose [:i {:class "fa fa-caret-right"}] (map (fn [crumb] [:span {:key crumb} crumb]) crumbs))

curlyfry15:11:53

The above gives the Warning: Every element in a seq should have a unique :key: warning (since the arrow icons don't have :key attributes), which is quite annoying and forces me to use less nice ways of solving the problem. Anyone else annoyed by/have a way to deal with this?

jjfine16:11:48

@curlyfry is a pure css solution possible? a selector like .crumb + .crumb might work since your interposed element doesn't have any data

mccraigmccraig16:11:08

@curlyfry if you put your sequence into a [:div] then you will swerve the warning... it wouldn't be as performant for changes to a long sequence, but breadcrumbs are probably not going to be a very long sequence

upgradingdave18:11:25

@curlyfry, maybe you could use (gensym)? Something like (interpose [:i {:key (str (gensym)) :class "fa fa-caret-right"}] (map (fn [crumb] [:span {:key crumb} crumb]) ["home" "profile"]))

upgradingdave18:11:37

doh, or maybe not … because I think gensym will only get evaluated once 😅

curlyfry19:11:57

@jjfine @mccraigmccraig @upgradingdave Thanks guys, will check it out tomorrow!