Fork me on GitHub
#om
<
2017-01-04
>
SoV403:01:45

Question: I'm doing some dev testing with an atom that has nested values... (atom { :blurbs { 0 {:blurb/id 0 :blurb/title "Hey!" :blurb/content "Greeting message" }}}) What's the appropriate way to write a read function for nested maps? (subvec) I know is for vectors... I just discovered again the get-in statement ... (get-in @atom [:blurbs 0 :blurb/title]) ... I'm trying to turn this into a UI query expression ... any thoughts?

SoV403:01:07

I'm not sure how to translate my atom-parsing into IQuery. My read function for :blurb/content looks like `(defmethod read :blurb/content [{:keys [state] :as env} key params] (let [st @state] (get-in st [:blurbs (:blurb-id params) :blurb/content])))` What would be the right thing to pass to om/IQuery in my ui component so I can render :blurb/content based on id?

SoV407:01:11

nevermind, got it working. ... how can I make sure every component has a unique react key? I'm getting some funky errs

SoV407:01:57

"react.inc.js:18745 Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of nonforum_starter_january$core$BlurbList. See https://fb.me/react-warning-keys for more information." ...

SoV407:01:04

did not mean to link that ^

SoV407:01:22

just, the error about react-keys got me looking for solutions.

drcode14:01:01

@sova to make sure each component has a unique key, declare a key function in the om/factory declaration: (def foo-component (om/factory Foo {:keyfn :db/id}))

stuartsierra20:01:11

How do you set the initial local state of an Om.next component?

stuartsierra20:01:58

To answer my question: implement Object (initLocalState [this] {:foo 42}) in defui

SoV422:01:51

@drcode thank you that helps point me in the right direction...

SoV422:01:09

@drcode ah you're a saint. what worked for me was (def blurb (om/factory Blurb {:keyfn :id}) because my elements already have unique :id

SoV422:01:18

Question: if I am moving my app from an @atom to <datomic> then presumably all I need to change are my parser :readfn and :mutatefns, yes?

ag22:01:22

in shouldComponentUpdate how to parse next-props ?