reagent

Michelle Lim 2023-05-08T13:52:17.478859Z

is there a way to prevent a component from rerendering when the parent component updates?

eval-on-point 2023-05-08T14:03:30.406859Z

Do you want the parent to re-render, or do you actually want only some of the descendants of the parent to re-render?

Michelle Lim 2023-05-08T14:46:30.221249Z

the parent receives new data, that only one child needs, and the other child is a hover element that should retain its open state

eval-on-point 2023-05-08T15:12:16.858449Z

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.

Michelle Lim 2023-05-08T15:32:12.913909Z

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

Michelle Lim 2023-05-08T15:34:42.233179Z

each row has an element that opens a preview modal on hover, and that's what i want to prevent repainting

eval-on-point 2023-05-08T16:06:16.243189Z

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

lsenjov 2023-05-09T01:53:23.563429Z

Are you using unique keys on each row of your table?

Michelle Lim 2023-05-19T20:41:09.249089Z

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