Fork me on GitHub
#om
<
2016-05-03
>
devth13:05:07

if I call initLocalState, the result has some container {:omcljs$state {:my-state :football}} wrapped around it. i think this is preventing me from doing: (om/set-state! c (.initLocalState c)) <— this sets an invalid state

anmonteiro13:05:34

@devth: initLocalState is not supposed to be called directly

devth13:05:20

anmonteiro: i'm trying to reset a form. seemed like a good way

anmonteiro13:05:12

@devth: make a function init-state or w/e and call it both in initLocalState and in the reset code

devth13:05:35

anmonteiro: that'll work. thx

Lambda/Sierra14:05:25

How do you best debug "Warning: Each child in an array or iterator should have a unique 'key' prop"?

roberto14:05:08

I saw that warning first in reagent. It happened when I was displaying a collection and didn’t provide a unique identifying key

roberto14:05:15

my naive way of solving that was to assoc an id key with a unique value, there is probably a more idiomatic way of doing this

Lambda/Sierra15:05:49

I've encountered it fairly frequently, and sometimes it is hard to figure out which element is causing the problem.

jplaza15:05:40

This happens to me all the time, I usually create fns that receive collections and then use them like this: (defn [& children] (dom/div nil children))

anmonteiro17:05:23

this is a fun one, and not related to the dynamic queries patch

anmonteiro17:05:08

I don’t think we’ve ever tried to have joins in recursive queries

anmonteiro17:05:13

so a query like [{:tree [:id {:counter [:value]} {:children ...}]}] breaks when we have paths such as [:tree :children :counter]

anmonteiro17:05:28

because we only index [:tree :children] and [:tree :counter]

dnolen17:05:48

@anmonteiro: sorry is there a typo in your example? Where’s the join? i.e. map in map?

anmonteiro17:05:33

@dnolen: not sure if there’s a typo, the join in this case would be {:counter [:value]}

dnolen17:05:02

oops sorry … was thinking union

anmonteiro17:05:03

every other bit of code are the data paths

dnolen17:05:30

@anmonteiro: ah, hmm, seems to me like that should just work - would need to take a look to understand why it doesn't

anmonteiro17:05:55

1. class-path uses take-while

anmonteiro17:05:11

2. the build-index function stops at first recursion

anmonteiro17:05:58

so a class-path like Comp Child Child Counter is actually computed as Comp Child

anmonteiro17:05:02

because of take-while

anmonteiro17:05:14

I’m looking into it if that’s OK, should make for a fun one

andrewchumich21:05:49

@stuartsierra : If you are iterating over a list and mapping a component to each value, use :keyfn id in om.next/factory. Example:

Lambda/Sierra21:05:47

I'm using om.now. When I call build-all I know to add a :key. But sometimes the warning shows up in other places, for example if I am conditionally rendering some components.