bluesky-social / social-app

The Bluesky Social application for Web, iOS, and Android
https://bsky.app
MIT License
11.82k stars 1.51k forks source link

Extract RepostButton inner dialog #6498

Closed gaearon closed 3 days ago

gaearon commented 4 days ago

The usual refactor to avoid creating JSX eagerly.

Test Plan

Repost button and dialog still works on iOS, Android.

github-actions[bot] commented 4 days ago
Old size New size Diff
8.05 MB 8.05 MB 0 B (0.00%)

wojtekmaj commented 2 days ago

Curious, how does this prevent eager JSX creation? Since the new, extracted function does not contain e.g. an early return, I would expect identical JSX to be created before and after. 🤔

gaearon commented 2 days ago

JSX is lazy, so <Foo /> doesn't call Foo unless React recursively gets to it via the parent tree. In this case, <Dialog.Outer> conditionally renders its children, so it would never get to the inner child while the dialog is closed.