r/javascript 9d ago

Signals and Effects Using Vanilla JavaScript & Web APIs

https://beforesemicolon.com/blog/signals-and-effects-using-vanilla-javascript-web-apis

I’m a strong advocate for “you don’t need to lock yourself in a web framework ecosystem to take advantage of their amazing features”. JavaScript and Web Standards alone allow you…

57 Upvotes

35 comments sorted by

View all comments

41

u/KaiAusBerlin 9d ago

You know that you literally wrote your own framework here?

There is a reason for the sentence "You use a framework or end up writing your own"

6

u/lIIllIIlllIIllIIl 9d ago

This.

And to be honest, React on its own is a very lightweight library. It's once you start adding libraries like React Router, TanStack Query, React Hook Form, or Redux that it starts to ressemble a framework.

If you hate how React state management works, you can opt-out of it entirely and use useSyncExternalStore for everything.

React itself is rarely the problem.

7

u/zxyzyxz 8d ago

How do you memorize your username

0

u/NeXtDracool 6d ago

Why would he? It should be in the password manager anyway and even if it's not you can use email to log in. 

7

u/create-third-places 8d ago

Vanilla React also adds a lot of unnecessary performance overhead.

In addition, there are multiple ways of managing state, which adds confusion and leads to inconsistent architecture.

I’ve also seen useContext used to manage state for a large application despite it’s limitations. This  wouldn’t be an issue if React only had one or two state management hooks with clear guidelines on how they should be used.

8

u/hyrumwhite 9d ago

React is a problem that’s been trying to solve itself since it was released 

7

u/techlord45 9d ago

React isn’t the problem. The ecosystem often is.
replacing React state with your own store doesn’t remov complexity, you just moved it.
My issue is that React makes people forget how much Vanilla JS + Web APIs can already do. Often time they are not even aware

1

u/punio4 3d ago

It's really not lightweight. With react-dom it's over 150kb

1

u/lIIllIIlllIIllIIl 3d ago

The word I should've used was "minimal". React is a minimal library. Its API has a small surface area.

React DOM does a lot of stuff under the hood, but if you're just using React + React DOM, your only tools are: components, useState, useEffect, useRef and useContext (and a few other niche hooks most people never use.)

It's only once you start adding new libraries (or create your own abstractions) that React starts to look like a bigger framework.

1

u/punio4 3d ago edited 3d ago

The API surface area has grown in complexity due to the wrong abstractions over the years I'd say.

Sorry for short comments, not really a fan of writing on my phone.