3 ms·
In JS, frameworks have helped us to work out which bits of "magic" we really value, and over the past 5-7 years especially, that has informed the evolution of t
by jeffmcmahan 6y ago
In JS, frameworks have helped us to work out which bits of "magic" we really value, and over the past 5-7 years especially, that has informed the evolution of the language. And now, most of what we'd want is built into the platform (raucous applause). I build pretty much everything - from simple to very complex - with arrow function closures and direct DOM manip, and it works beautifully. I occasionally use lit-html if I really need to to make quick progress. But otherwise, it's the raw DOM API with one simple, functional pattern...
- wildrhythms 6y agoAny 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.
- anderspitman 6y agoThe 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/components/directory.js#L69 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.
- jeffmcmahan 6y agoI 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.
- arthurcolle 6y agoDon't tell that to all the React developers, you might get banned from working in web!
- Mandolean 6y agoThis is a fantastic book about Frameworkless Front-end Development https://www.apress.com/us/book/9781484249666 https://www.apress.com/us/book/9781484249666. After I bought it I discovered that the Author is one of the founders of the Movement itself. You may also find the code of the book on GitHub https://github.com/Apress/frameworkless-front-end-development https://github.com/Apress/frameworkless-front-end-developmen...