This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-27
Channels
- # announcements (10)
- # beginners (95)
- # biff (2)
- # calva (33)
- # cherry (1)
- # clj-kondo (16)
- # clojure (96)
- # clojure-australia (1)
- # clojure-china (1)
- # clojure-europe (42)
- # clojure-filipino (1)
- # clojure-france (2)
- # clojure-hk (1)
- # clojure-indonesia (1)
- # clojure-japan (1)
- # clojure-korea (1)
- # clojure-my (1)
- # clojure-nl (1)
- # clojure-norway (24)
- # clojure-sg (11)
- # clojure-taiwan (1)
- # clojure-uk (1)
- # clojurescript (21)
- # cursive (22)
- # data-science (3)
- # events (7)
- # fulcro (3)
- # graalvm (4)
- # gratitude (6)
- # helix (11)
- # honeysql (7)
- # hoplon (1)
- # introduce-yourself (1)
- # jobs (2)
- # jobs-discuss (16)
- # lsp (15)
- # malli (14)
- # nbb (73)
- # practicalli (3)
- # reagent (8)
- # reitit (5)
- # releases (1)
- # ring (5)
- # rum (3)
- # sci (17)
- # scittle (7)
- # shadow-cljs (22)
- # tools-deps (26)
- # xtdb (9)
is there a way to force all, or some set, of a component’s children to re-render when ANY of the children are updated? I know this isn’t quite “idiomatic”…
but the mutable object that I am reactifying, the Board
, has a 1-layer-deep set of children, and adds them all in order. later children in the list can depend on earlier children (`Angle` is defined by supplying the IDs of three Point
s that have already been added for example);
so if any of the points change, I want to remove and re-add everything that came after that Point
. Or, simpler, just re-render the entire child set when the properties of any children change.
is there some way to trigger that?
the best way I can imagine is to
• make a ratom with a :forceUpdate
key
• pass it to all children
• any time a child updates, it can (swap! !state update :forceUpdate inc)
hi it's me again! This is probably not what you want ultimately but you can at least prototype to see if it works with reagent.dom/force-update-all!
https://reagent-project.github.io/docs/master/reagent.dom.html
But being free from idiomatic conventions can be so darn liberating 😁 and we've already left kansas so why not
I bet that will work, but I will say that it would be nice to have it only apply to all the children, or even better all the children including and AFTER the one that is updated
The former I can do, the latter probably is not necessary as an optimization…
But that is great advice, if rerender all doesn’t work then I’ll know there is something else fishy with mutability that would have been harder to discover without this
You may be able to use a combination of https://reagent-project.github.io/docs/master/reagent.core.html#var-current-component and https://reactjs.org/docs/react-component.html#forceupdate
I realized that with the amount of mutable state going on under the hood, I really can’t be clever at all here, and need to re-render ALL children any time anything changes for any of them.
this makes the code simpler… instead of forceupdate and friends, I
• keep a ratom with a counter,
• increment the counter every time render
is called on the JSXGraph
top level component
• pass the mutable board
instance and the counter value along as a prop to every child
then each child adds itself to the board
every time component-did-update
is called.
not perfect but until the underlying library is more amenable, this is pretty good!