Fork me on GitHub
#om
<
2016-04-22
>
currentoor04:04:05

Is it ok for two different components to have the same ident?

tomjack05:04:47

I think it is OK

tomjack05:04:42

the indexer appears to keep a map from idents to sets of components

tomjack05:04:31

also it seems necessary

jimmy10:04:21

@hlolli: regarding react key while using sablono you can do something like this 1. use index as key (map-indexed (fn [x i] [:el {:key i})) 2. use an attr in x as key (map (fn [x] [:el {:key (:attr x)}])) 3. if the element here is a component, you can use keyfn from om.

hlolli11:04:11

@nxqd Well, how about uniqueness, I do 2 times map indexed and I have few elements with key 0, 1, 2, 3..etc. But looks like a good solution. But overall, this is only a warning, everything works like it is suppose to. So Im trying to understand (by reading react docs) to why react wants unique keys. And I wonder if sablono library should be set to do this automatically as well.

jimmy11:04:57

@hlolli: sab doesn't seem to do it. in react 15, react does restrict key even more agressively. I just try react 15 and have to hold back for the upcoming release, some of the parts don't work with react 15 because of the react key. I believe they do some optimization to flatten the tree so it requires react key to work well. Regarding the unique, it depends on the element path, as long as it's unique within it's siblings then it's fine. You can use (random-uuid) if you want

hlolli11:04:34

ahh ok, then it isn't a problem with map-indexed. So after a cup of coffee I will fix this error message. Thanks!

isak16:04:07

@hlolli: @nxqd: what i noticed before is that you can give React two DOMs which will turn into the same actual DOM after flattening, and one will give a warning and one will not

isak16:04:58

with sablano you seem to get a lot of false warnings because it is less common to bother flattening things

isak16:04:06

i think React is doing the key warning logic in the wrong place in their engine

isak16:04:15

@hlolli: @nxqd : here is a codepen that demonstrates: http://codepen.io/isaksky/pen/jPpYqr

isak16:04:51

as you can see react complains about keys, even though it has no problem sorting it out in reality (try typing in the fields)

isak16:04:23

oh wait, i think i made it mess up (it looses focus)

isak16:04:32

so i guess it is warning correctly, the diff is just not very smart

seberius20:04:08

@hlolli I have had success doing this for Sablono (sab/html [:div (into [:ul.mylist] (map (fn [x] [:li.myitem x]) list-items))])

tony.kay20:04:26

Did tempid handling change from alpha31 to 32?

anmonteiro21:04:50

@tony.kay: not that I’m aware

tony.kay21:04:31

yeah, I see you made sure to merge queries

tony.kay21:04:46

ok...probably just a weirdness on my end

grounded_sage22:04:39

Where are the solutions for the Om Devcards Tutorial ?

tomconroy23:04:31

hello, i'm trying to implement an om-next remote that talks to a postgresql database. i'm a little confused on something... i have a ui with a simple list of elements with a query like [{:items/list [:id :title]}] and a button that does [(items/insert {:title "foo"})]. the mutate function for 'items/insert simply returns {:remote true}, and then on the server it returns {:action (fn [] (db/insert params)) :value {:keys [:items/list]}}. what i expect is when i hit the button, the frontend list updates with the new item, but nothing happens... if i refresh the page i can see the new item. i think what i'm missing is, should the :action function return a value (which appears to be placed in the :results key) – what should it return?

grounded_sage23:04:35

I'm in UI_Exercises and stuck on Exercise 4. Declared deletePerson {:onDelete (fn [p] (js/console.log "delete" p))} in the let binding of PeopleWidget. Passed it to om-person with (om/computed people deletePerson) pulled the :onDelete key with {:keys [onDelete]} (om/get-computed this) in the let binding of Person. Added it to the button with #js (:onClick #(onDelete name)) and I get nothing. I've referred back to the first UI example with callbacks and played around with it but I am stumped.