How to set default variable in JSX for const with selector

I am fairly experienced with PHP and WordPress theming, but now struggling with the new Gutenberg editor. I have created a custom block plugin, which involves a lot of JS (React). To the latter I am a bit new. The block is creating a simple wrapper div with a html lang attribute assigned to it based on the input of a selector. The following code is working fine, however only when the selector is changed. By default the langCode variable remains empty. Any idea what goes wrong? Answer This should be working: EDIT: Couldn’t reproduce the still existing error. So