Skip to content

Commit 636ddcb

Browse files
Lendemormasenf
authored andcommitted
reduce badge perf impact on pages (#4872)
* reduce badge perf impact on pages * small fixes
1 parent 031adc9 commit 636ddcb

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

reflex/app.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -986,12 +986,15 @@ def _setup_overlay_component(self):
986986

987987
def _setup_sticky_badge(self):
988988
"""Add the sticky badge to the app."""
989-
for k, component in self._pages.items():
990-
# Would be nice to share single sticky_badge across all pages, but
991-
# it bungles the StatefulComponent compile step.
989+
from reflex.components.component import memo
990+
991+
@memo
992+
def memoized_badge():
992993
sticky_badge = sticky()
993994
sticky_badge._add_style_recursive({})
994-
self._pages[k] = Fragment.create(sticky_badge, component)
995+
return sticky_badge
996+
997+
self.app_wraps[(0, "StickyBadge")] = lambda _: memoized_badge()
995998

996999
def _apply_decorated_pages(self):
9971000
"""Add @rx.page decorated pages to the app.

0 commit comments

Comments
 (0)