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

Migrate from Context API to Zustand #248

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

Prathamm-sahu
Copy link
Contributor

Description

This PR refactors the application’s state management from Context API to Zustand to improve performance, reduce unnecessary re-renders, and simplify state handling.

Related Issue

Fixes #243

Changes Made

  • Removed Context API-based state management.
  • Introduced Zustand for more efficient state handling.
  • Updated all components to use Zustand instead of useContext.

Checklist

Please ensure the following before submitting your PR:

  • I have reviewed the project's contribution guidelines.
  • I have written unit tests for the changes (if applicable).
  • I have updated the documentation (if applicable).
  • I have tested the changes locally and ensured they work as expected.
  • My code follows the project's coding standards.

@clubanderson
Copy link
Contributor

@manzil-infinity180 @MAVRICK-1 how does this work with or interfere with our redis work?

@manzil-infinity180
Copy link
Member

manzil-infinity180 commented Feb 27, 2025

@manzil-infinity180 @MAVRICK-1 how does this work with or interfere with our redis work?

its not related to Redis, it is for better state management for react

I think we need to go with context API, in future we will plan depend on our usecases

@Prathamm-sahu
Copy link
Contributor Author

@manzil-infinity180 Yeah but I think in future it will become more difficult to migrate to zustand because as the project grows it might become more messy to deal with changes.

@MAVRICK-1
Copy link
Member

Zustand is a better choice than Context API for our use case as it improves performance by reducing unnecessary re-renders and offers a simpler, more scalable state management approach. Unlike Context API, which re-renders all consumers on state updates, Zustand uses a subscription-based model, ensuring only relevant components update. It integrates well with your Go backend, Redis caching, and Kubernetes API client, making real-time updates and state persistence more efficient. For performance and scalability, Zustand is the right choice..

@MAVRICK-1
Copy link
Member

@clubanderson Zustand handles frontend state efficiently, while Redis caches Kubernetes data in the backend. The Go backend fetches data from Redis first before querying the Kubernetes API. Zustand reduces unnecessary re-renders, ensuring smooth UI updates without directly interacting with Redis.

@clubanderson
Copy link
Contributor

ahh, I see. ok - so is this ready to merge?

@clubanderson
Copy link
Contributor

check is failing - need that fixed first

@Prathamm-sahu
Copy link
Contributor Author

check is failing - need that fixed first
Yeah I working on it

@manzil-infinity180
Copy link
Member

manzil-infinity180 commented Feb 27, 2025

check is failing - need that fixed first

@clubanderson get approval from frontend guys too

@manzil-infinity180
Copy link
Member

check is failing - need that fixed first
Yeah I working on it

its listing error , fix it

error 'useContext' is defined but never used @typescript-eslint/no-unused-vars

@MAVRICK-1
Copy link
Member

/hold

@MAVRICK-1
Copy link
Member

MAVRICK-1 commented Feb 27, 2025

Screenshot from 2025-02-27 23-59-05

@Prathamm-sahu,

Could you please clarify how you checked it? The backend was not functional due to duplicate handlers. Kindly verify it before raising any PR.

I also checked the CI, and I’m curious why it didn’t return any errors . I will fix that.
Please keep this in mind for next time.

Thank you for your contribution! 😊

@manzil-infinity180
Copy link
Member

manzil-infinity180 commented Feb 27, 2025

Screenshot from 2025-02-27 23-59-05

@Prathamm-sahu,

Could you please clarify how you checked it? The backend was not functional due to duplicate handlers. Kindly verify it before raising any PR.

I also checked the CI, and I’m curious why it didn’t return any errors . I will fix that. Please keep this in mind for next time.

Thank you for your contribution! 😊

Yeah same happen with kunal pr too, like he have duplicate import issue even after this his test passed on ci

@MAVRICK-1
Copy link
Member

Screenshot from 2025-02-28 00-34-29
@manzil-infinity180
getting 500 for api/wds/workerload
could you please double check it

@manzil-infinity180
Copy link
Member

Screenshot from 2025-02-28 00-34-29 @manzil-infinity180 getting 500 for api/wds/workerload could you please double check it

I will confirm you tomorrow , previously it was running fine

i guess i have issues with my cluster i am experimenting with my kubeconfig file
Screenshot 2025-02-28 at 12 47 31 AM

@RealRTorres
Copy link
Contributor

Everything looks good and the cluster table still functions. I agree with migrating to Zustland now before the project gets bigger, since it helps with performance. I approve of this.

@manzil-infinity180
Copy link
Member

Screenshot from 2025-02-28 00-34-29 @manzil-infinity180 getting 500 for api/wds/workerload could you please double check it

No issues @MAVRICK-1 ( from updated dev branch)
Screenshot 2025-02-28 at 1 19 19 AM

@MAVRICK-1
Copy link
Member

@manzil-infinity180 dev branch is working fine for me also

@Prathamm-sahu
Copy link
Contributor Author

Screenshot from 2025-02-27 23-59-05

@Prathamm-sahu,

Could you please clarify how you checked it? The backend was not functional due to duplicate handlers. Kindly verify it before raising any PR.

I also checked the CI, and I’m curious why it didn’t return any errors . I will fix that. Please keep this in mind for next time.

Thank you for your contribution! 😊

@MAVRICK-1
When I raised the PR backend and frontend both were working fine and I haven't made any changes to backend I have only made changes in frontend. This error appears because of kunal's PR which was merged before

@MAVRICK-1
Copy link
Member

@Prathamm-sahu okay got it , no issues

@github-actions github-actions bot removed the backend label Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

[FEATURE] Refactor State Management: Migrate from Context API to Zustand
5 participants