by erikpukinskis · 7y ago · 0 comments
But only because React, with transpiling and the shadow DOM and all that is so inscrutable.
There’s no hope of understanding the DOM with React, no hope of understanding styles with styled-components. There’s no hope of placing a breakpoint in your code and tracing forward through events. No hope of understanding stack traces.
The DevTools begin to address some of those deficiencies. It does help, but still leaves me thinking the tradeoffs weren’t worth it. You can never reach simplicity, only manageable complexity. In the long run it leaves an opportunity for a new generation of tools that respect JavaScript and the DOM.
You can still understand the DOM in a React driven app though. The component output is there for anyone to read. I do that every day. All React is doing is generating DOM content and then working out the smallest update necessary when the state changes. The problem that React Devtools addresses is that it's the component output that's there, not the components themselves. There's more information behind the scenes, and that is what React Devtools lets you peek in to.
It does help, but still leaves me thinking the tradeoffs weren’t worth it.
You have to reason about the way you write code, what your apps need, and what works best for your users. If the tradeoff is that using React's features means you can no longer work with the complexity of what's happening in the browser and that's slowing down your development process then don't use React. Your development process and your users are way more important than any framework.
Not to use too-harsh language but that's a cop-out in my opinion. Yes, some tools are better for a given job than others. But we're working with general-purpose machinery for the purpose of building UIs and applications. There isn't really a differing set of requirements or problems in that domain. ... and if that's true, then it means that one size should actually fit all. I think, personally, UIKit is excellent. I think people don't understand how to use it properly… they don't understand how to write good imperative code, so they look to a declarative system as a way around that… but I think they're only deferring the inevitable or shifting non-problem-inherent complexity they couldn't initially solve.
I remember AngularJS well, that’s a framework I can do without.
That's a bit of a stretch. What debuggers are /you/ using?
A great phrase that puts my feelings about React or any other front-end JS framework into words. Thanks for that.
100% agreed. May I shamelessly plug my enormously positive experience with Elm here, with DOM being DOM, always-present time-travelling debugger, no runtime exceptions and other nicities? Main point is that you don't have to do the tradeoffs sometimes if you go full way towards a different, pure, statically-typed language.
The analog of styled-components exists, but I never used it, just regular BEM+SCSS.
This is false. I've been developing with React for over a year and a half and have never used the React dev tools. I've only ever used the browser's web inspector and it's fine. We don't write CSS in JS, so this could play in to that, but when we were evaluating those solutions it wasn't impossible to figure out what was going on, even if you had hashes for class names.
Dom explorer shows the elements. document.querySelector finds your tags. Css just works. Nothing new to learn.
Custom elements let you be just another html tag and do your magic. Not fully sold on shadow dom but web components api is simple and I love it.
CSS has of course always worked just fine with React (as does LESS and SASS). Styled-components is totally optional.
There's tradeoffs at scale with trying to use an imperative style of coding with document.querySelector or JQuery. Fine for simple websites. Absolutely awful for complex web apps with large teams.
Dom explorer is still a tab in Chrome for react devs. I readily switch between the React devtools and Dom explorer all the time.
The reason in my mind, for React, is that it's a higher level, functional abstraction above the DOM that makes complex web development manageable.
That's an understandable but dangerous attitude for a web developer to take.
After showing the HTML you can still make elements more interactive with things like jQuery, Stimulus or Freudjs (disclaimer: my own)
So you mean something like keeping state of forms in something like redux and sending out an event every time you press a button so that state gets update and the change is pushed down the tree of elements so that the letter you just pressed gets rendered in the form?
Or did you mean client side validations of forms that you also have in your back-end?
Obviously you didn't and I am being a bit of an ass, but this is what is the somewhat recommended way of going around this and it is so convoluted.
> doing a lot of manual labour keeping track of all states, events, etc.
The state of most web applications can be kept inside of DOM elements and the url just fine.
> What div is visible, which one to hide, which buttons to disable
This is where CSS-classes and the aforementioned JS libraries come in and they do this job just fine.
> adding new rows into forms dynamically with pre-populated values... that kind of stuff is way (and I mean waaaay) easier when coded in a declarative reactive way.
I don't believe you are right. It is not easier at all to add some DOM elements with React than it is when you use small bits of JS. Let's say you use jQuery, then it is 1 dependency you add with a small wrapper script for your dynamic form, with React you add thousands of dependencies and you have to build your complete application in React just to dynamically add a row in one of the forms. How is that easier?
I don't think I'd build Slack mostly using HTML rendering from the back-end, but most of the things that we build are CRUD applications that can easily be built using things like Ruby on Rails. Let's say the Trello's, Githubs and Amazons of our world.
Indeed.
I mean who'd do that when there are plenty of server-side templating solutions that don't have to live by React's constraints (vdom/DOM diffing) only making things difficult? The only use case for React SSR seems quick first-page rendering and SEO.
SSR and "PRPL"-style hydration are totally compatible with React. See Gatsby's intro docs for a great example.
Agree. IMHO the fact that React uses the virtual DOM is one of its biggest inconveniences.
> In the long run it leaves an opportunity for a new generation of tools that respect JavaScript and the DOM.
Angular (v. >= 2.x.x) on this is much simpler to understand as it manipulates the DOM directly. With the built-in dev tools of any browser you pretty much can inspect any portion of HTML, CSS and source code.