This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-19
Channels
- # aws-lambda (4)
- # beginners (62)
- # cider (20)
- # cljs-dev (9)
- # cljsrn (13)
- # clojars (3)
- # clojure (105)
- # clojure-brasil (1)
- # clojure-denver (1)
- # clojure-finland (4)
- # clojure-italy (23)
- # clojure-norway (1)
- # clojure-spec (6)
- # clojure-uk (56)
- # clojurescript (41)
- # cursive (10)
- # datomic (25)
- # emacs (23)
- # figwheel (2)
- # fulcro (133)
- # graphql (12)
- # hoplon (32)
- # instaparse (13)
- # keechma (1)
- # lein-figwheel (1)
- # luminus (1)
- # lumo (1)
- # nyc (2)
- # off-topic (34)
- # om (2)
- # onyx (10)
- # pedestal (8)
- # portkey (1)
- # re-frame (10)
- # reagent (26)
- # ring (8)
- # shadow-cljs (77)
- # spacemacs (4)
- # sql (8)
- # tools-deps (15)
- # vim (9)
Reagent 0.8.0 is now out: https://github.com/reagent-project/reagent/blob/master/CHANGELOG.md#080-2018-04-19
:<>
looks handy
Thanks Juho!!
I was wondering, in plain React you can have the problem that setState is called in a promise, and that the component is already unmounted while the promise is still running. Then you get the error: âTrying to call setState on an unmounted component.â Why have I never seen this error in Reagent? đ
@erwinrooijakkers itâs certainly possible to make that mistake in reagent, but I think with idiomatic reagent you would never use reactâs state mechanism: instead youâd just to reagentâs atom mechanism. if you update an atom after an unmount, it wonât cause an error: the atom will get updated but there just wonât be a watcher on it
Thanks
And in React we have to use this state management mechanism? It doesnât have something like Reagent atoms?
you donât have to use react state. many people use an external library like redux or react saga to implement the so called âfluxâ one-way dataflow. or something like mobx. mobx is probably most similar to the reagent ratom technique. they both basically implement an observer pattern
but nothing is as solid as reagentâs atoms because it isnât possible to fully proxy javascript arrays in the current language, so you have to be very careful to code to a convention with mobx
Thanks clear. Yes redux is used, but setState as well
right. i guess the most straightforward answer is that if you need setState in react, the idomatic way of doing that in reagent is with a form-2 component and a locally declared ratom
Yeah which is much less to worry about
somewhere i read (probably on twitter) that the setState interface was a design concession and meant as something transitional. the react people really wanted a declarative immutable style because the problem they were trying to solve was actually code correctness (not speed)
Hi Everybody Is it possible to use render props pattern with reagent?
Thanks I m able to make it work with render prop. Some how it was not working with children prop May be I m missing something
well, keep in mind that reagent has a funny way of distinguishing between children and props. if the first argument to the component function is a map, then that is treated as the âpropsâ. all other arguments are just children.
I did not know that before Will keep this in mind Thanks again for the help đ
@umardaraz4747 @lee.justin.m just FYI, this doc https://github.com/reagent-project/reagent/blob/master/docs/InteropWithReact.md#getting-props-and-children-of-current-component seems somewhat relevant as far as Reagent props vs children vs React handling
If i use a ratom inside of a function (instead of directly inside of a component), will it still reactively re-render?
e.g.
(def store (r/atom {:copy {"123" "some copy"))
(defn get-copy [id]
(get-in [:copy id] @store))
(defn component [id]
(let [copy (get-copy id)]
[:div copy]))
@lilactown it should rerender if you are calling the function from inside the component (like you are). However, I think there is a subtle bug in the get-copy function.. @store and [:copy id] should be switched.