Skip to content

Full Body Re-renders When Selecting a Sample from "Load Sample" Dropdown #330

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

Open
surya4419 opened this issue Mar 26, 2025 · 1 comment · May be fixed by #338
Open

Full Body Re-renders When Selecting a Sample from "Load Sample" Dropdown #330

surya4419 opened this issue Mar 26, 2025 · 1 comment · May be fixed by #338

Comments

@surya4419
Copy link
Contributor

Bug Report 🐛

When selecting an option from the "Load Sample" dropdown, the entire body section re-renders, causing unnecessary reloads.

Expected Behavior

Only the relevant section (e.g., the editor or preview panel) should update when a sample is loaded. The rest of the UI should remain unchanged to improve performance and user experience.

Current Behavior

  • The entire body section reloads instead of just updating the required component.
  • This leads to unnecessary API calls and potential UI flickering.
  • Performance is affected due to repeated re-renders.

Possible Solution

  • Optimize state management so that only the necessary components update.
  • Use React.memo, useMemo, or useCallback to prevent unnecessary renders.
  • Ensure the API call for fetching sample data does not trigger a full-page update.

Steps to Reproduce

  1. Open the application.
  2. Navigate to the "Load Sample" dropdown.
  3. Select any sample from the dropdown list.
  4. Observe that the entire body reloads instead of just updating the relevant section.

Context (Environment)

Desktop

  • OS: [e.g., Windows 11]
  • Browser: [e.g., Chrome 120.0.6099.71]
  • Version: [e.g., 0.22.15]

Detailed Description

The issue seems to be caused by a state update at a higher level, leading to a full component tree re-render. It should be scoped only to the affected components, avoiding unnecessary re-renders and redundant API calls.

Possible Implementation

  • Refactor the Load Sample state to be more granular.
  • Utilize React Context or useReducer to manage the data efficiently.
  • Avoid setting state in a way that forces a complete re-render of the parent container.
@surya4419
Copy link
Contributor Author

Hey @DianaLease , I’ve already worked on this issue and will be raising a PR soon. Could you please assign it to me? Thanks!

@surya4419 surya4419 linked a pull request Mar 28, 2025 that will close this issue
4 tasks
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 a pull request may close this issue.

1 participant