瀏覽代碼

raise error on private events (#5152)

Khaleel Al-Adhami 1 月之前
父節點
當前提交
351ac2ac58
共有 1 個文件被更改,包括 2 次插入0 次删除
  1. 2 0
      reflex/event.py

+ 2 - 0
reflex/event.py

@@ -2064,6 +2064,8 @@ class EventNamespace:
                         "Background task must be async function or generator."
                     )
                 setattr(func, BACKGROUND_TASK_MARKER, True)
+            if getattr(func, "__name__", "").startswith("_"):
+                raise ValueError("Event handlers cannot be private.")
             return func  # pyright: ignore [reportReturnType]
 
         if func is not None: