Fork me on GitHub
#reagent
<
2017-08-05
>
captainlexington17:08:37

My understanding is that when you use a reagent component like [foo] it uses the react life cycle and when use one like (foo) it doesn't. Is this true? If so, is there a way to map a component over something and use the life-cycle version?

deadghost18:08:50

@captainlexington don't recall if map works because I've been using for for this for a long time

noisesmith18:08:25

@captainlexington you can also use (into [some-component] (map ...)) for some cases

noisesmith18:08:50

so you end up with a vector with your component for the life cycle, but you can use map to generate the args

noisesmith18:08:13

(of course you could also change the function to take a lazy-seq as its only arg and get the same result)

captainlexington18:08:31

@deadghost What's the pattern for using for instead?

deadghost18:08:44

@captainlexington `(for [x [1 2 3]] ^{:key (str "comp-" x)} [component])`

captainlexington18:08:10

@deadghost I'll give it a shot, thanks!