5 ms·
I guess “React makes sense for more complex UIs” is not hard-and-fast rule. jQuery, apparently, is more than enough for clean working frontend code.
by divbzero 3y ago
I guess “React makes sense for more complex UIs” is not hard-and-fast rule. jQuery, apparently, is more than enough for clean working frontend code.
- omeid2 3y agoIt is not about complex UI per se, it is about complex state. With jQuery, the State is duplicated in the DOM instead of mirrored and is very hard to keep in sync.
- FpUser 3y ago>"State is duplicated in the DOM instead of mirrored" And the difference between duplicated and mirrored is ...
- deleted 3y ago[deleted]
- omeid2 3y agoFair question. Mirrored means when you update state, your changes are reflected in the DOM, automagically. Duplicated means when you change state, you also have to make the changes to the DOM, yourself.
- divbzero 3y agoClear (mostly one-way) data binding is definitely one of React’s strengths. It appears that Puter handles templating with a pattern like: let h = `` h += `<div>${exampleContent}</div>` h += `<div>${moreExampleContent}</div>` $(targetEl).append(h) And handles events in the traditional way: $(targetEl).on('click', function () { /* do stuff */ }); Searching for “React” or “jQuery” in this thread, there are several other conversations with thoughtful comments about pros and cons. One curious tidbit that I learned is that Visual Studio Code doesn’t use a framework either and, like Puter, updates the DOM directly.
- omeid2 3y agoThe main issue is that "$(targetEl).append(h)" is not idempotent. This might seem like a small issue on the surface but as your application grows, this either becomes a big problem or you have reinvented React, Vue, or something similar, but without the extensive testing and developer/community availability. Which is essentially what VSCode does for example, using some sort of MVP* pattern.
- deleted 3y ago[deleted]
- djbusby 3y agoWrite state to DOM, read state from DOM.
- omeid2 3y agoIn sounds nice in theory, but in practice, it doesn't work out. The example linked is a good one, a popover, the underlying DOM disappears, but the "state" behind it remains at least a bit longer.
- QuadrupleA 3y agoI've practiced for decades and it works out fine. It's good to explore outside the React cargo cult from time to time.
- omeid2 3y agoCan you share some complex application you have worked on that doesn't use a framework or end-up inventing one internally like VSCode for example? I did web not just before React but before jQuery and MooTools. So it is funny you ask I should explore outside "React cargo cult".
- lenkite 3y agoOut of curiosity, which is the internal framework used by VSCode ? Would like to take a look at that. According to Erich Gamma, there is no use of a UI framework just a conventional model-View-Presenter with JS/TS constructed HTMLElement components.
- omeid2 3y agoThere is no such thing as "conventional" MVP, every implementation is slightly different. It is not an official framework per se, but it is a framework nonetheless, except without comprehensive documentation and developer availability or much commercial value in investing your time to learn it. The main point is that if you're arguing against React or any framework "because abstraction bad", you will end up with them anyways, enjoy: https://github.com/microsoft/vscode/blob/release/1.87/src/vs/base/common/lifecycle.ts https://github.com/microsoft/vscode/blob/release/1.87/src/vs... https://github.com/microsoft/vscode/blob/release/1.87/src/vs/base/common/event.ts https://github.com/microsoft/vscode/blob/release/1.87/src/vs... https://github.com/microsoft/vscode/blob/release/1.87/src/vs/base/common/actions.ts https://github.com/microsoft/vscode/blob/release/1.87/src/vs...
- rtcoms 3y agoWhy not use a state management library like xstate with jQuery ?
- xorcist 3y agoThere is no sync if the state is the DOM.
- deleted 3y ago[deleted]