DEV Community

Guilherme Samuel
Guilherme Samuel

Posted on • Originally published at guilhermefront.com

3 Simple ideas for a better ReactJS

React has certainly made a notable stride on the quality of our DX. Features like hooks were major breakthroughs on how we develop client side applications. It is important to note however, that even though React has matured a lot, there is still plenty of room for innovation and improvement. We're currently heading towards a merge between the client and server, which is going to be a costly shift in the things we are going to have to deal with and care about. I hope that these long term plans work out, but while we watch this progression, I have a few ideas that could impact React on the short term.

1. Bring something like a platform-agnostic Zustand

Zustand is a simple state management library capable of covering most of our needs of small to medium size state complexity. It has an insignificant learning curve and solves the problems of using state anywhere much more gracefully than the current built-in alternative way of accomplishing it (context API, which isn't a state management library to begin with and needs to be tied to a parent component). Bringing something like this to the core would encourage the simplicity and easiness that Zustand tackles state managemente.

2. Release the docs as it is, improvements can come later.

It is been several years since the docs are outdated. Still using hooks. The perfectionism here completely outweighed the benefits of just releasing what is already good. It should be released a while ago, even if we don't have a proper landing page.

3. Make the React DevTools relevant again.

I don't know if is either because a core contributor isn't there anymore or the roadmap was completed, but this project is pretty much stale.
As we're moving towards SSR, would be useful to have some new features there to help us debug server related problems, for example:

  • Possibility to go back between renders to check the differences between server and client (to better identify hydration mismatches)
  • Visualize suspense data
  • Check for waterfall requests
  • See which components are RSC and which are client, etc

Implementing these short term ideas could have a significant impact on the React community and make our development experience even better.

Top comments (7)

Collapse
 
brense profile image
Rense Bakker

Agree with all except the first point. The power of react is exactly that it doesn't force you into an opinionated state management library like Zustand. Zustand is just one of many different options for state management. Some prefer jotai (same author I believe) for example, or xstate or even framework agnostic state management solutions... Being unopinionated is React's strongest selling point.

Collapse
 
guilhermefront profile image
Guilherme Samuel

What means being "opinionated" for you? What would differ using Context API with useReducer or useState not be an opinionated solution compared to Zustand? I don't think there's a difference at all (zustand also labels itself as unopinionated).

Bringing something like Zustand (not specifically Zustand) wouldn't hurt the possibility of using something else, it will just have the benefit of having a great default library to manage state.

I also don't think being unopinionated is React's strongest selling point, NextJS is our main framework to developing production ready react apps and is very opinionated. React just doesn't lock you into one path, but bringing a tiny library to manage state wouldn't change that.

Collapse
 
brense profile image
Rense Bakker

React does a little more than not lock you into one path. Nobody at React said you have to use NextJS, infact the two have no affiliation. The developers who use React chose what they want to use. Currently NextJS is popular, in a few years from now, maybe another framework will be popular. That is the point of being unopinionated. Maybe Zustand is popular now (Redux is still the most used, btw...) on a later date, some other state management library will be popular. If they add Zustand to the core of React, it will strongly influence developers chosing to use React and it will become very hard for other state management libraries to gain popularity, even if they are better. Thats why its important for React to stay unopinionated and they are doing a great job.

Does the developer of Zustand even want Zustand to be added to the core of React btw? I think not.

Thread Thread
 
guilhermefront profile image
Guilherme Samuel

The reason I bring nextjs isn't about having affiliation, is just that being un-opinionated isn't React main selling point. NextJS is the primary way of developing React applications and is very opinionated.

Does the developer of Zustand even want Zustand to be added to the core of React btw? I think not.
I don't know if I was clear about this. Doesn't need specifically to be Zustand. React just needs some solution like it.
Dan tweeted about this sometime ago:
twitter.com/dan_abramov/status/162...
twitter.com/dan_abramov/status/162...

Thread Thread
 
brense profile image
Rense Bakker

Nextjs is not the primary way of developing react applications and even if it was, that still doesn't make react opinionated. Nobody at react said everyone should use nextjs and there's nothing in the react core that tells you to use nextjs. Its your own choice as a developer to use nextjs with react or not... Aka: unopinionated.

Thread Thread
 
guilhermefront profile image
Guilherme Samuel

I don't see where we're going with this, but nextjs is really the way of developing React applications nowadays. Check any chart or whatever data is available today. Btw acdlite from the react core team said everybody should be using a framework.

Thread Thread
 
brense profile image
Rense Bakker

Agreed, this isn't going anywhere.