My ad for web components: btw I used to use react
Why I don't miss React: a story about using the platform
41–50 of 279 posts
Re: Why I don't miss React: a story about using the platform
#42React works well for simple, non-interactive components. Complex, interactive components are going to have state. Stateful components don't work so well in React. If you want to update props in a stateful component, the recommendation is to replace the component entirely by changing its key. At the point all of the benefits of React (preservation of selection, caret position, scroll position etc.) vanish. You might a…
> React works well for simple, non-interactive components. Complex, interactive components are going to have state. Stateful components don't work so well in React
React components are designed with state in mind. When state changes, components passed that state in the form of props are re-rendered. Don't take my word for it though, from the first paragraph on the reactjs.org website; "React makes it painless to create interactive UIs. Design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes."
> At the point all of the benefits of React (preservation of selection, caret position, scroll position etc.) vanish.
I have never heard these spouted as the benefits of React. The main fundamental philosophy of React is that only components that have state changing "react" to changes - in other words, the benefits of React are: no unnecessary re-rendering (hence the virtual DOM).
> If you want to update props in a stateful component, the recommendation is to replace the component entirely by changing its key
This part just threw me, if you are doing it this way - you are doing it wrong.
Re: Why I don't miss React: a story about using the platform
#43> Was this slightly more work than using a library from npm? > I'd definitely recommend using a library for this, and we settled on lit-html (link to library from npm) This article is mostly about switching from React to Lit. You can use modern web APIs (like FormData) with React, FormData's not a replacement for state management. You can use Web Components with React, the way Fluent UI does ( https://docs.microsoft.…
Anyone know what is going on with lit-? Their TypeScript starter is painfully bloated and outdated and never seems to keep pace. I actually ended up looking at microsoft/fast for my use case but that seems to be stale in some way. I kind of feel that given the "simplicity" of a single class wrapping custom elements, everything is pretty boring. Note: I cannot do better.
Re: Why I don't miss React: a story about using the platform
#44I'm moving towards vanilla JavaScript for my platform, and one of the things that I've discovered is that if you have a reactive data source then you don't need a lot of framework. Granted, I'm taking advantage that the core platform is much more stable than a decade ago.
What is a reactive data source?
Re: Why I don't miss React: a story about using the platform
#45Re: Why I don't miss React: a story about using the platform
#46We now use a JSX renderer that emits plain HTML strings.
You get all the ergonomics, the IDE assistance of checking for typos in your attributes, ensuring your closing tags line up, and webpack can flatten it back to plain HTML at compile-time for no run-time __jsx / React.createElement() calls.
Re: Why I don't miss React: a story about using the platform
#47Earlier quoted context omitted.
Anyone know what is going on with lit-? Their TypeScript starter is painfully bloated and outdated and never seems to keep pace. I actually ended up looking at microsoft/fast for my use case but that seems to be stale in some way. I kind of feel that given the "simplicity" of a single class wrapping custom elements, everything is pretty boring. Note: I cannot do better.
I feel like google does web component frameworks like it does messaging apps. Each new one is the silver bullet. I wouldn't build on any google web framework personally, even if it claims to be oh so simple and lightweight.
Re: Why I don't miss React: a story about using the platform
#48If all you need is a couple of basic forms and some basic interaction, you can do it all with vanilla JS but let's not kid ourselves. This will not allow you to build very rich apps without implementing a significant chunk of the frameworks you dislike so much. In fact, I would even say that if this is not a core part of your product, you are simply wasting time and resources. There is a huge amount of man-hours pour…
> of the frameworks you dislike so much This is totally uncalled for. He's not attacking you. He's explaining a tradeoff, very reasonably. > I would even say that if this is not a core part of your product, you are simply wasting time and resources. I find especially interesting that this phrase can be used to defend both sides of the argument. If you are building a highly rich application, chances are that using a f…
Re: Why I don't miss React: a story about using the platform
#49W3C standardized Web Components before React existed and took off, unfortunately. I expect the next standard to just be React itself (or a barebones version that the library can build on top of), patent licenses permitting. I'm pretty sure as a C++ precompile, it would be unstoppable and end the debate for good.
Re: Why I don't miss React: a story about using the platform
#50Aren't web components more of an addition to frameworks like Bootstrap than a React replacement?
I don't think so. I want to wrap webgl games with a custom component, and they share basic UI (which are also custom component dependencies). But none of this has anything to do with the larger web application (Angular) which manages much much more. So stuck with iframes which although I can hide to some extent, are terrible.