From cebc5982f361fc9cbadce82bd4d3a92ef043a630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Brand=C3=A9ho?= Date: Thu, 10 Aug 2023 20:21:45 +0200 Subject: [PATCH] fix missing on_load parameter in custom_404 (#1541) --- reflex/app.py | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/reflex/app.py b/reflex/app.py index 0a1963ae9..07ea1d134 100644 --- a/reflex/app.py +++ b/reflex/app.py @@ -404,11 +404,14 @@ class App(Base): def add_custom_404_page( 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. @@ -420,25 +423,19 @@ class App(Base): title: The title of the page. description: The description of 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. """ - 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, ) - froute = format.format_route - self.pages[froute(constants.SLUG_404)] = component - def setup_admin_dash(self): """Setup the admin dash.""" # Get the config.