krishnaacharyaa / wanderlust

WanderLust is a MERN travel blog website 🚀 This project is aimed to help people to contribute in open source, upskill in react and master git.
https://wanderlust-beta.vercel.app/
MIT License
194 stars 1.07k forks source link

[ENHANCEMENT] Adding a centralized state (Redux/MobX/Recoil) #92

Open SujayDas1999 opened 8 months ago

SujayDas1999 commented 8 months ago

Description

I have been going through the react code and I have an enhancement suggestion. Instead of using use state, can we migrate the application to use a centralized state such as Redux/MobX/Recoil ?

Current Behavior

The jsx files uses use state hook. There is no centralized state.

Proposed Enhancement

To implement Redux like centralized state management system.

Use Case

To implement Redux like centralized state management system by which a state can be used my multiple components without using props or drilling down props (if props are required).

Blockers

No response

Additional Information/ Attachments

No response

krishnaacharyaa commented 8 months ago

Yes @SujayDas1999, Thank you for opening this issue, we can aim for RTK query, and we can aim for the latest and minimalistic state management, because using redux will be an overhead for application of this small scale, Interested to know your thoughts if you are open to working on this.

SujayDas1999 commented 8 months ago

I would suggest to use Zustand/Recoil since the code effort will be way less than using RTK query. It is simple & and minimalistic.

Zustand :- https://zustand-demo.pmnd.rs/ Recoil :- https://recoiljs.org/

Please let me know your thoughts on this.

[Edit] Apologies for the confusion. But I believe that RTK Query is used for querying the API. In this enhancement I am talking about plain state management like having a centralized state which will be accessible to all components irrespective of their relation for which we have to use Redux Took-Kit (since you are looking for a minimalistic approach). Should we be using both RTK Query + Redux Toolkit combined ? Or just RTK Query ?

krishnaacharyaa commented 8 months ago

Okay sounds interesting, Can we discuss about this in the discord... Once we agree to an approach we'll go with that

SujayDas1999 commented 7 months ago

Hi @krishnaacharyaa please let me know when we can connect on discord

krishnaacharyaa commented 7 months ago

Hi @SujayDas1999 , I have messaged in the discord kindly look into..

theEdgeBreaker commented 5 months ago

Hi @krishnaacharyaa, I would like to add Redux Toolkit.

krishnaacharyaa commented 5 months ago

Hi @theEdgeBreaker Actually after multiple iterations we wanted to go with zustand, can you please let us know what is the adv and dis of redux toolkit and zustand from there we can pick this

theEdgeBreaker commented 5 months ago

Hi @krishnaacharyaa, Reason for Redux is that it has larger and robust community and we can get more people contributing later if needed in Redux as compared to Zustand. If someone is working in this project for learning then they'll be more demanding in Industry as Redux is used in Large scale projects which hires people. Ultimately some day this project might also grow. I can pick any of them but in case of Redux Toolkit, I can finish the setup in few days time.

krishnaacharyaa commented 5 months ago

@theEdgeBreaker Thank you for the detailed opinion and thinking about the future contributors... Yeah all the points you said are really vaild, but here, why we were thinking of zustand is ... The project in the future scope even won't scale to the extent that we have to use redux and it creates too much boilerplate for a simple blog application and might make people anxious by seeing it as it's aimed for new people to dive in and learn MERN and to understand the not soo complex project....

So for the present scenario and even for the foreseeable future we wouldn't want to use redux as the project won't go that crazy complex... So we can go with the trending zustand, which is robust as redux but reduces the very much boilerplate of redux and can handle even if the project scales ...

So we came to this discussion of using zustand.... This would be a rather decent change aimed to simplify the things than complicating it ....

You might ask,Why do we need state management afterall? It a simple app working just fine without it, it is simple the way it is... Answer is because of the bug https://github.com/krishnaacharyaa/wanderlust/issues/98 Which can be handled by state management... Aggreed we can also solve it using localstorage.... But thought it would be nice to have decent state management to handle this ...

krishnaacharyaa commented 5 months ago

Hi @theEdgeBreaker May I know if you wanna take this up? I'll assign it to you....

theEdgeBreaker commented 5 months ago

Hello @krishnaacharyaa, Yes you can assign me this, I want to work on it.

krishnaacharyaa commented 5 months ago

Sure @theEdgeBreaker, let us work on the MVP and as mentioned let's try to resolve the bug which I mentioned in the previous comment....first and then let's see if there is any further scope....

krishnaacharyaa commented 5 months ago

Hi @theEdgeBreaker , may i know the update on this, and how much further time it would roughly take ?

theEdgeBreaker commented 5 months ago

Hi @krishnaacharyaa, I used Zustand but the bug wasn't resolved, so I'm trying another approach. I'll give you updates today

krishnaacharyaa commented 5 months ago

@theEdgeBreaker raise PR, let's see... I guess we can solve that without state management, one guy is working on it,

krishnaacharyaa commented 5 months ago

Hi @theEdgeBreaker, the issue is solved here https://github.com/krishnaacharyaa/wanderlust/pull/116#pullrequestreview-1968755303, Pardon me, I haven't actually went through that, Now I am just wondering what will be the scope of using State management as Zustand now karke... Do you have any take on this?

theEdgeBreaker commented 5 months ago

Hi @krishnaacharyaa, I don't think Zustand played any role in this, so I'll look into another one to address.

krishnaacharyaa commented 5 months ago

Yeah exactly @theEdgeBreaker .

"so I'll look into another one to address."

Didn't get you

krishnaacharyaa commented 5 months ago

I'm just wondering now, why we need zustand as simple as the question gets !

theEdgeBreaker commented 5 months ago

@krishnaacharyaa, I'll take another issue to solve, Probably issue #70.

krishnaacharyaa commented 5 months ago

@theEdgeBreaker Sure, Just let us know the appraoch before implementing

krishnaacharyaa commented 5 months ago

@theEdgeBreaker Were you able to find some issue worth contributing?