Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommend zustand for global state management #715

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MalcolmTomisin
Copy link

  • Zustand has a similar API to Redux (Selectors etc)
  • Way less boilerplate
  • Growing popularity as Redux's gets limited to legacy codebases
  • New projects get set up with new generation state managers (Tanstack-query, Valtio, MST, Zustand)
  • Zustand is lighweight, lightweight is important for React Native
  • Performant with transient updates that don't cause re-renders

@pangolingo
Copy link

Is the mobile team using Zustand a lot? I've never worked with it. I'd love to see how we're using it on our client work.

@MalcolmTomisin
Copy link
Author

MalcolmTomisin commented Sep 20, 2024

@pangolingo I don't think there has been opportunities to experience Zustand on client work. New projects are more likely to use zustand.
We are currently looking at writing a series of React Native and Rails blog posts. Zustand and Redux comparisons may feature in one of those posts.

@pangolingo
Copy link

I suggest that we convert this PR to a draft, and don't merge until until more thoughtbotters have enough first-hand experience to recommend Zustand over Redux.

@codeofdiego
Copy link

Hi @pangolingo, yeah I like that suggestion. Ideally, we should get more experience with Zustand and adoption on client projects before changing the guide. @MalcolmTomisin I really liked the idea of writing a blog post about comparing both.

@MalcolmTomisin MalcolmTomisin marked this pull request as draft September 27, 2024 14:13
@rakeshpetit
Copy link
Contributor

rakeshpetit commented Nov 6, 2024

Zustand is lighweight, lightweight is important for React Native

React Native apps package all code into a single bundle which means the impact on lightweight library is very minimal.

Performant with transient updates that don't cause re-renders

I'm ready to be on the side of redux with this and fight you :)

Growing popularity as Redux's gets limited to legacy codebases
New projects get set up with new generation state managers (Tanstack-query, Valtio, MST, Zustand)

We use Ruby on Rails as our web stack which is 20 years old, stable and just works. While we should focus on adopting modern solutions, instead of chasing them, we should be carefully choosing them.

I think we should be introducing new libraries in a client project first to test suitability, identify problems, and gather team feedback before recommending broader adoption such as updating our guides.
Example: Tanstack query (React query) that has been used in a few client projects reaping benefits with an enjoyable developer experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants