ソースを参照

fix onload method not working in prod mode (#2049)

Thomas Brandého 1 年間 前
コミット
edf9c32142
1 ファイル変更8 行追加7 行削除
  1. 8 7
      reflex/app.py

+ 8 - 7
reflex/app.py

@@ -614,6 +614,14 @@ class App(Base):
 
     def compile(self):
         """Compile the app and output it to the pages folder."""
+        # add the pages before the compile check so App know onload methods
+        for render, kwargs in DECORATED_PAGES:
+            self.add_page(render, **kwargs)
+
+        # Render a default 404 page if the user didn't supply one
+        if constants.Page404.SLUG not in self.pages:
+            self.add_custom_404_page()
+
         if not self._should_compile():
             return
 
@@ -624,13 +632,6 @@ class App(Base):
             TimeElapsedColumn(),
         )
 
-        for render, kwargs in DECORATED_PAGES:
-            self.add_page(render, **kwargs)
-
-        # Render a default 404 page if the user didn't supply one
-        if constants.Page404.SLUG not in self.pages:
-            self.add_custom_404_page()
-
         task = progress.add_task("Compiling: ", total=len(self.pages))
         # TODO: include all work done in progress indicator, not just self.pages