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

Feat: Optimize Indicator Component with React.memo #126

Open
Arindam200 opened this issue Jun 19, 2024 · 2 comments
Open

Feat: Optimize Indicator Component with React.memo #126

Arindam200 opened this issue Jun 19, 2024 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers in the OSP Community. up for grabs issues that are open for contributors

Comments

@Arindam200
Copy link
Contributor

Description

The Indicator component currently re-renders whenever its parent component re-renders, even if the osVersion state has not changed. This can lead to performance issues, especially if the parent component re-renders frequently. To optimize the Indicator component, we should wrap it with React.memo to prevent unnecessary re-renders.

Proposed Solution

Use React.memo to wrap the Indicator component. This higher-order component will perform a shallow comparison of the component's props and only re-render if the props have changed.

Detailed Steps

  1. Import React.memo:

    • Ensure React is imported in the Indicator.tsx file.
  2. Wrap the Component:

    • Wrap the Indicator component with React.memo when exporting it. This will optimize the component by preventing unnecessary re-renders.
  3. Verify Functionality:

    • Ensure that the Indicator component still functions correctly and updates when the osVersion state changes.

Benefits

  • Performance Improvement: By preventing unnecessary re-renders, the application will perform better, especially if the parent component re-renders frequently.
  • Optimized Rendering: React.memo ensures that the Indicator component only re-renders when its props change, leading to more efficient rendering.
@Arindam200 Arindam200 added the enhancement New feature or request label Jun 19, 2024
@Arindam-at-Pieces Arindam-at-Pieces added good first issue Good for newcomers in the OSP Community. up for grabs issues that are open for contributors labels Jun 19, 2024
@OlibhiaGhosh
Copy link
Contributor

I would like to work on this issue

@Arindam200
Copy link
Contributor Author

Go ahead @OlibhiaGhosh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers in the OSP Community. up for grabs issues that are open for contributors
Projects
None yet
Development

No branches or pull requests

3 participants