This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-11
Channels
- # announcements (1)
- # aws (4)
- # beginners (16)
- # cider (9)
- # cljs-dev (3)
- # cljsrn (2)
- # clojure (46)
- # clojure-brasil (1)
- # clojure-spec (3)
- # clojure-uk (4)
- # clojurescript (46)
- # cursive (26)
- # duct (1)
- # emacs (31)
- # figwheel (1)
- # fulcro (9)
- # graalvm (21)
- # kaocha (1)
- # nyc (1)
- # off-topic (4)
- # pathom (6)
- # planck (45)
- # re-frame (2)
- # reagent (11)
- # ring (5)
- # rum (9)
- # spacemacs (2)
- # sql (60)
- # tools-deps (3)
are there tutorials about how to do the normal "this.state.props" idiom in reagent? is everything handled by global or let-bound r/atoms?
I don’t recall, but personally I tend to pass them as arguments to the component function and if necessary bind that to the r/atom.
@nbtheduke what are you interested in doing?
:component-did-update
fn needs to know what the change is. i can't quite do this with component-will-update
, because i need to pass information between the two, so i instead set a flag on an atom and check the flag
i have a chat message window, and i want it to scroll only when i'm scrolled to the bottom
the code is not written super cleanly, lol, so this is more challenging than i'dhoped
The general solution for state management with Reagent would be atoms, yes, so you should not need to reach for something like this.state.props
. For example, I have reimplemented non-trivial React components like Drag and Drop, Resize-able containers and Material Ripple Effects and used atoms for these.
But its difficult to say without seeing code.
My issue I think is that dealing with defonce
'd atoms feels like a code smell, given that globals are generally a bad idea
@nbtheduke sounds like there’s a few things going on:
1. You shouldn’t need to use component-did-update
, etc. in general with reagent, unless you really know what you’re doing. I’d have to know more about your problem.
2. I’m not sure what you mean by "this.state.props" idiom
. generally, tracking props in state is an anti-pattern in React
3. your aversion to globals is warranted, which is why I try and maintain most of my state in let-bound atoms. This becomes difficult as your application grows, though.