Hacker News new | past | comments | ask | show | jobs | submit login

Any advice for rendering lists? I usually start down this path of building the elements and appending them to some container element, but as soon as I need to update a single element in the list, I end up re-rendering the entire list... with a gigantic list this can start to become problematic.



The approach I've been taking is using the source data to determine what index needs to change, and using the dom to swap out just that element. Here's an example:

https://github.com/remfs/remfs-delver-js/blob/master/compone...

Don't look to closely at the code as a whole. It's prototype quality.


I have a simple reconcile function (that I wrote, in umpteen variations) diff the previous and upcoming view state (not the DOM state) for each list item, and if there are changes or new items, the changes are made. If not, DOM nodes are not touched.

FWIW, it is actually nice to take hold of the details. In many situations you realize that you can alter the way things work to achieve cool effects or performance gains or whatever. Things you don't imagine or explore when React is just going to do whatever it does on your behalf.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: