4 ms·
I‘ve written a UI a few months ago with only lithtml and direct DOM manipulation and it worked pretty well. I needed to do calculations and reading bounding bo
by dgb23 3y ago
I‘ve written a UI a few months ago with only lithtml and direct DOM manipulation and it worked pretty well.
I needed to do calculations and reading bounding boxes from the DOM initially and on resize. Basically a hack to get around CSS limitations.
It was crucial that this is fast enough to avoid flickering.
I wouldn’t have attempted this with react. I think it would still be possible with useEffect, but I tried the most lightweight and fast by default approach that was feasible.
Have a look at lithtml.
- shaunxcode 3y agoin the cljs/reagent world anytime you need to do direct dom stuff you just use a ref - that must me the same for react proper?
- dgb23 3y agoYou can pretty much do anything with a combination of refs, events and useEffect. It’s often fiddly and cumbersome though. Aside: That’s why I‘ve been gravitating towards approaches that have much simpler execution models. You can still do declarative and functional. But you have more control when needed, create _much_ smaller bundles, have fewer dependencies, better default performance, allocate less garbage and you can reason about your code in more fundamental ways. In cljs this would mean to not use a react wrapper. However I personally try to avoid using any deps for frontend, and that includes cljs. Any dep needs a justification IMO. That justification is often not good enough, since I’m mostly writing „interactive documents with some fancy parts“. If you’re writing something like nextjournal, roam, data rabbit or similar then it’s a different story.