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

Render post menu items lazily (take two) #6473

Merged
merged 5 commits into from
Nov 19, 2024
Merged

Render post menu items lazily (take two) #6473

merged 5 commits into from
Nov 19, 2024

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Nov 17, 2024

Resubmit of #6437.

I broke dialogs in #6437. We can't put dialogs inside the <Menu.Outer> conditionally rendered content because that would destroy their state and controls, and those need to be alive even after the dialog is closed.

Now I'm unreverting it but applying a few more fixes on top:

  • 6b1640?w=1 applies a slightly different approach. The dialogs are placed outside of <Menu.Outer> so that they don't depend on the menu open/close state. However, the menu itself is not rendered until the first time you press the button. In other words, the menu is now initialized lazily.
  • In ac29593, I move the new component to another file so that we can take advantage of lazy requires where it works.
  • Finally, f03a6c1 tweaks the implementation because useMenuControl only has isOpen for web and I can't figure out how to fix that. This new implementation is ugly but works cross-platform.

Test Plan

Verify the menu works. Verify the dialogs within the menu also work (unlike last time). Verify you can toggle the menu repeatedly. Refresh the page and verify that you can also toggle the menu (both once and repeatedly) using keyboard.

Do this on all platforms.

Copy link

github-actions bot commented Nov 17, 2024

Old size New size Diff
8.05 MB 8.05 MB 0 B (0.00%)

This is wonky because our useMenuDialog abstraction only has `isOpen` on web. I couldn't figure out a way to make it work xplat so I'm just tracking it myself manually.
@arcalinea arcalinea temporarily deployed to unrevert-perf-fix - social-app PR #6473 November 19, 2024 14:57 — with Render Destroyed
Copy link
Contributor

@haileyok haileyok left a comment

Choose a reason for hiding this comment

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

Nice. Tested on web where it was broken before and it looks good. Did not test on device, but the code looks correct.

@gaearon gaearon merged commit 31b0d7c into main Nov 19, 2024
6 checks passed
@mozzius
Copy link
Member

mozzius commented Nov 19, 2024

Tested on all platforms, works well

@mozzius mozzius deleted the unrevert-perf-fix branch November 19, 2024 18:50
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