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

webui: Don't use inline functional component for router's Switch to avoid unnecessary re-renders. #336

Merged
merged 3 commits into from
Mar 27, 2024

Conversation

junhaoliao
Copy link
Member

@junhaoliao junhaoliao commented Mar 26, 2024

References

Internally it was found that collapsing / expanding the sidebar would clear the search results. Further investigation found that the search page was re-rendered when the isSidebarCollapsed state variable got updated, causing unnecessary and undesired re-render of page contents.

It was also identified that the pseudo user authentication system is no longer in use and can be removed.

Description

  1. Remove user login methods and related UI components.
  2. Rename React root component to root which is a more standard convention.
     

Validation performed

  1. cd <PROJECT_ROOT>; task
  2. cd ./build/clp-package/sbin; ./start-clp.sh
  3. ./compress.sh ~/samples/hive-24hr/i-00c90a0f/
  4. Opened the WebUI address in a browser.
  5. Started a query with string 123 and observed the job finished and the results are displayed in the results table.
  6. Clicked the "Collapse" button to collapse the sidebar and observed the results still present within the search page.
  7. Clicked the "Expand" button to expand the sidebar and observed the results still present within the search page.

@junhaoliao
Copy link
Member Author

Please put this review on hold. Let me also remove the unused user authentication system in this PR instead.

…t component to `root` which is a more standard convention.
@junhaoliao
Copy link
Member Author

junhaoliao commented Mar 26, 2024

The changes are pushed, and the PR descriptions have been updated. Please resume the review.

Copy link
Member

@kirkrodrigues kirkrodrigues left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

webui: Don't use an expression to render routes to avoid unnecessary re-renders. (#336)

(At least that's my understanding of the issue.)

@junhaoliao
Copy link
Member Author

How about:

webui: Don't use an expression to render routes to avoid unnecessary re-renders. (#336)

(At least that's my understanding of the issue.)

JSX itself is an expression, but sometimes React is smart enough to avoid re-evaluation of the JSX. The initial fix does exactly that although the routeSwtich constant was later inlined. Supposedly another fix is to keep the <Routes/> as a component and move it out of the <App/>.

It might be more clear to say webui: Avoid unnecessary React route-switch re-render within functional components. (#336). What do you think?

@junhaoliao junhaoliao merged commit 6afb506 into y-scope:main Mar 27, 2024
1 check passed
@kirkrodrigues kirkrodrigues changed the title webui: Fix a bug where collapsing the sidebar clears the search results. webui: Don't use inline functional component for router's Switch to avoid unnecessary re-renders. Mar 27, 2024
@junhaoliao junhaoliao deleted the collapse-rerender branch April 16, 2024 07:32
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.

2 participants