This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-05-08
Channels
- # announcements (1)
- # babashka (28)
- # beginners (13)
- # calva (10)
- # clerk (18)
- # clj-on-windows (39)
- # clj-otel (1)
- # cljdoc (17)
- # clojars (12)
- # clojure (40)
- # clojure-austin (11)
- # clojure-brasil (1)
- # clojure-europe (23)
- # clojure-nl (3)
- # clojure-norway (16)
- # clojure-uk (2)
- # clojurescript (28)
- # clr (4)
- # conjure (1)
- # emacs (14)
- # hoplon (6)
- # hyperfiddle (59)
- # interop (2)
- # leiningen (1)
- # off-topic (37)
- # pathom (1)
- # polylith (5)
- # portal (7)
- # reagent (9)
- # releases (3)
- # shadow-cljs (22)
- # spacemacs (6)
- # tools-build (12)
- # tools-deps (51)
- # web-security (6)
- # xtdb (7)
is there a way to prevent a component from rerendering when the parent component updates?
Do you want the parent to re-render, or do you actually want only some of the descendants of the parent to re-render?
the parent receives new data, that only one child needs, and the other child is a hover element that should retain its open state
Awesome, then you can rewrite your component so that neither the parent nor the hover element re-render. Only the child that needs the state should rerender. Have you seen this guide? [reagent/WhenDoComponentsUpdate.md at master · reagent-project/reagent · GitHub](https://github.com/reagent-project/reagent/blob/master/doc/WhenDoComponentsUpdate.md) It probably has what you need.
that makes sense. my problem is that the parent is a sortable table with data updating in real-time. to sort the rows by attribute, the table needs to be aware of each row's data. it subscribes to a list of data which is mapped over to render each row. but this data updates every few seconds, which causes the entire table to rerender
each row has an element that opens a preview modal on hover, and that's what i want to prevent repainting
Ah, I see the issue now. I'm no frontend guru so there is probably a better solution, but I would probably decouple the lifecycle of the modal from the table. Have the table push new state to the app-db on hovers and just make the modal reflect that state
thanks for your thoughts! i made it work by only referencing the real-time data in two specific places — the element that displays it, and the sort handler — instead of passing it to the overall table. so the sort handler updates the table order on demand, instead of the table re-ordering itself whenever data changes. we decided we're ok with the rows not re-ordering in real time