From 8c01fdbfdc5dfe902c5bbbbdd6b05ef31a54b3a6 Mon Sep 17 00:00:00 2001 From: Lendemor Date: Wed, 11 Dec 2024 23:49:37 +0100 Subject: [PATCH] reuse data_callback name if already set during first call to add_hooks --- reflex/components/datadisplay/dataeditor.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/reflex/components/datadisplay/dataeditor.py b/reflex/components/datadisplay/dataeditor.py index 93352c291..3b5692576 100644 --- a/reflex/components/datadisplay/dataeditor.py +++ b/reflex/components/datadisplay/dataeditor.py @@ -360,8 +360,11 @@ class DataEditor(NoSSRComponent): editor_id = get_unique_variable_name() # Define the name of the getData callback associated with this component and assign to get_cell_content. - data_callback = f"getData_{editor_id}" - self.get_cell_content = Var(_js_expr=data_callback) # type: ignore + if self.get_cell_content is not None: + data_callback = self.get_cell_content._js_expr + else: + data_callback = f"getData_{editor_id}" + self.get_cell_content = Var(_js_expr=data_callback) # type: ignore code = [f"function {data_callback}([col, row])" "{"]