Custom Element and wp_localize_script in Builder

Hi Devs,

I create a custom Element and set the $scripts-attribute for my js-function to load in the builder:

public $scripts = ['tg__setupElement'];

i do enqueue the js-file in the enqueue_scripts()-function of the Element.
In the render function I do pass data to the js-file:

wp_localize_script('tg_element_js', 'generalSettingsData', array(
                        'ajaxUrl' => admin_url('admin-ajax.php'),
                        'adminUrl' => admin_url(),
                        'rest_url' => rest_url(Constants::REST_NAMESPACE_VERSION_1 . Constants::REST_ROUTE_GET_EVENTS) ?? ' ',
                        'nonce' => wp_create_nonce('ajax-nonce'),

I now have the problem that my Element isn’t rendered in the builder when I insert it (it actually is rendered, when I save AND refresh the builder but that’s not what I want).

The error is that generalSettingsData is undefined. How would I pass the data so that it’s available to the Element when I insert it in the Builder?

Any help here? Would appreciate it!