diff --git a/reflex/components/props.py b/reflex/components/props.py index 2966e9727e..8736eca721 100644 --- a/reflex/components/props.py +++ b/reflex/components/props.py @@ -23,3 +23,20 @@ def json(self) -> str: return LiteralObjectVar.create( {format.to_camel_case(key): value for key, value in self.dict().items()} ).json() + + def dict(self, *args, **kwargs): + """Convert the object to a dictionary. + + Keys will be converted to camelCase. + + Args: + *args: Arguments to pass to the parent class. + **kwargs: Keyword arguments to pass to the parent class. + + Returns: + The object as a dictionary. + """ + return { + format.to_camel_case(key): value + for key, value in super().dict(*args, **kwargs).items() + } diff --git a/reflex/components/sonner/toast.py b/reflex/components/sonner/toast.py index c58b4a106c..c93b070449 100644 --- a/reflex/components/sonner/toast.py +++ b/reflex/components/sonner/toast.py @@ -171,12 +171,12 @@ def dict(self, *args, **kwargs) -> dict[str, Any]: d["cancel"] = self.cancel if isinstance(self.cancel, dict): d["cancel"] = ToastAction(**self.cancel) - if "on_dismiss" in d: - d["on_dismiss"] = format.format_queue_events( + if "onDismiss" in d: + d["onDismiss"] = format.format_queue_events( self.on_dismiss, _toast_callback_signature ) - if "on_auto_close" in d: - d["on_auto_close"] = format.format_queue_events( + if "onAutoClose" in d: + d["onAutoClose"] = format.format_queue_events( self.on_auto_close, _toast_callback_signature ) return d