DEV Community

Discussion on: React - You might not need that many states!

Collapse
 
bacloud22 profile image
aben • Edited

For a lazy developer like me, more lean to back-end, what would you suggest to have a semi synchronous front end without diving into React or any reactive programming library, something easy to grasp, two ways binding between front and back.
One example is a toggle button that would hit an api then change say the colour of the current card (toggled).
Basically, this is achievable using fetch and this is how I'm doing it, but is there any solution out there ?

thanks a lot Bruno

Collapse
 
noriller profile image
Bruno Noriller

This is a though one... with React you would have to use useEffect, useState everywhere, and personally, I'm doing the exact opposite where my backend end up as barren as possible.

The one thing that is comming to mind is to use something like Redux.
Every button clicked or action taken would dispatch something and the components would all be consuming that one state.
Even then, you would need fetches. (unless you could pull it off using websockes, but that depends on the type of project you have)

If you're already using javascript for the backend... then you might want to check Remix out because the components can end up pretty light and still react to any actions taken.

Collapse
 
bacloud22 profile image
aben

Thanks 🙏 Bruno.
I never heard of ReMix but it looks cool. I will try to go through their examples

Collapse
 
bacloud22 profile image
aben

I think that's the catch. It should not be a tough one. While everyone is concerned with reactive apps while building a regular website, no one thought let's make a client-UI/Server-api two way binding for years now!

Thread Thread
 
noriller profile image
Bruno Noriller

IMHO, I don't see a reason to put strain on a server when I can just as easily let the client handle all the state and whatever else.
I still need data from an API, but when using JAMStack, it can be basically anything.

The way you want it, it would probably be with websockets. I believe Blazor is doing something that.