This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-01
Channels
- # aleph (71)
- # aws (1)
- # bangalore-clj (4)
- # beginners (36)
- # boot (153)
- # cider (23)
- # clara (9)
- # cljs-dev (67)
- # cljsjs (2)
- # cljsrn (22)
- # clojure (348)
- # clojure-argentina (4)
- # clojure-austin (12)
- # clojure-berlin (9)
- # clojure-dusseldorf (6)
- # clojure-france (4)
- # clojure-italy (4)
- # clojure-russia (358)
- # clojure-spain (2)
- # clojure-spec (28)
- # clojure-uk (109)
- # clojurescript (130)
- # core-typed (1)
- # cursive (35)
- # datascript (6)
- # datomic (18)
- # emacs (12)
- # hoplon (4)
- # klipse (64)
- # lein-figwheel (13)
- # leiningen (3)
- # luminus (4)
- # lumo (51)
- # mount (22)
- # off-topic (83)
- # om (22)
- # om-next (8)
- # onyx (3)
- # pedestal (8)
- # perun (6)
- # portland-or (2)
- # re-frame (50)
- # ring (8)
- # ring-swagger (5)
- # untangled (10)
- # yada (9)
Hi all, creating my first Om Next app—hitting a case where I would like a component to have a custom react-key
, and also get props defined by the query.
If I pass the props to the factory, the component will have the custom props (`react-key`) on first render, but once a key defined in the query is updated, only the data defined by query is available via props.
e.g. when I create the component via factory:
(component {:react-key "abc"})
(om/props this)
inside render
returns {:rect-key "abc"}
but only on the first render.If component
defines IQuery
as, say, [:key1 :key2]
, once :key1
is updated in the app state, the props are {:key1 "value" :key2 "value"}
, the :react-key
is gone.
Is there a way to have both externally passed props and props available via the query?
@alexey_ You can create a factory with a :keyfn and it’ll use the provided function to calculate the react key. The function could be a keyword naming a prop, or just constantly return some value
e.g., (om.next/factory Component {:keyfn (constantly “abc”)})