This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-21
Channels
- # 100-days-of-code (6)
- # aleph (26)
- # beginners (129)
- # boot (5)
- # calva (3)
- # cider (5)
- # cljs-dev (16)
- # cljsrn (4)
- # clojure (204)
- # clojure-dev (36)
- # clojure-italy (23)
- # clojure-nl (4)
- # clojure-spec (221)
- # clojure-uk (60)
- # clojurescript (68)
- # datomic (47)
- # emacs (4)
- # figwheel-main (50)
- # fulcro (29)
- # graphql (10)
- # hyperfiddle (19)
- # lein-figwheel (3)
- # leiningen (20)
- # liberator (3)
- # off-topic (89)
- # onyx (15)
- # pedestal (1)
- # portkey (2)
- # re-frame (3)
- # reagent (6)
- # ring-swagger (1)
- # rum (12)
- # shadow-cljs (10)
- # uncomplicate (4)
- # vim (5)
I'm having an issue with rum components doing a full remount on state change. We are porting stuff from reagent where this does not happen. Is this generally how it works with rum, or am I doing something wrong?
should not happen, do you have a code snippet?
from the top of my head it could happen when rendering lists of items without providing :key
that’s not specific to any React wrappers though
Thanks for asking that question, @roman01la 😃 I found the problem when trying to shrink it down to a snippet. The problem was not in rum, nor in citrus, just in me.
@roman01la Can I init local state using props (rum/local {:qty <qty from props>} ::local-state)
?
I just want to work with original qty
from props and have a temporary one, so I can check if those qtys
are different and then I can enable button and apply changes
you can update local state in any event handler inside of a component or do it in a custom mixin within one of lifecycle methods, depends on when you want to update the state
Thanks. That’s exactly what I do. I don’t like it and will think about something better. 🙂 Thank you.
(defn derive-from-props [prop-getter state-key]
{:did-mount (fn [st]
(reset! (get st state-key) (prop-getter (:rum/args st)))
st)})
(rum/defc App <
(rum/local {} ::state)
(derive-from-props first ::state)
[_])
(App props)