소스 검색

fix missing on_load parameter in custom_404 (#1541)

Thomas Brandého 1 년 전
부모
커밋
cebc5982f3
1개의 변경된 파일16개의 추가작업 그리고 19개의 파일을 삭제
  1. 16 19
      reflex/app.py

+ 16 - 19
reflex/app.py

@@ -404,11 +404,14 @@ class App(Base):
 
 
     def add_custom_404_page(
     def add_custom_404_page(
         self,
         self,
-        component,
-        title=None,
-        image=None,
-        description=None,
-        meta=constants.DEFAULT_META_LIST,
+        component: Optional[Union[Component, ComponentCallable]] = None,
+        title: str = constants.TITLE_404,
+        image: str = constants.FAVICON_404,
+        description: str = constants.DESCRIPTION_404,
+        on_load: Optional[
+            Union[EventHandler, EventSpec, List[Union[EventHandler, EventSpec]]]
+        ] = None,
+        meta: List[Dict] = constants.DEFAULT_META_LIST,
     ):
     ):
         """Define a custom 404 page for any url having no match.
         """Define a custom 404 page for any url having no match.
 
 
@@ -420,25 +423,19 @@ class App(Base):
             title: The title of the page.
             title: The title of the page.
             description: The description of the page.
             description: The description of the page.
             image: The image to display on the page.
             image: The image to display on the page.
+            on_load: The event handler(s) that will be called each time the page load.
             meta: The metadata of the page.
             meta: The metadata of the page.
         """
         """
-        title = title or constants.TITLE_404
-        image = image or constants.FAVICON_404
-        description = description or constants.DESCRIPTION_404
-
-        component = component if isinstance(component, Component) else component()
-
-        compiler_utils.add_meta(
-            component,
-            title=title,
-            image=image,
-            description=description,
+        self.add_page(
+            component=component if component else Fragment.create(),
+            route=constants.SLUG_404,
+            title=title or constants.TITLE_404,
+            image=image or constants.FAVICON_404,
+            description=description or constants.DESCRIPTION_404,
+            on_load=on_load,
             meta=meta,
             meta=meta,
         )
         )
 
 
-        froute = format.format_route
-        self.pages[froute(constants.SLUG_404)] = component
-
     def setup_admin_dash(self):
     def setup_admin_dash(self):
         """Setup the admin dash."""
         """Setup the admin dash."""
         # Get the config.
         # Get the config.