How can I load webform content inside a custom webform composite element? I am using Drupal 8.7.3 and Webform 8.x-5.2. 

I created a custom composite field in a multistep webform by extending WebformCompositeBase. My users select a subject in an earlier step. In this step I want to take the key of the user selection and request data based on this key.

class OtherExpectationsComposite extends WebformCompositeBase {
    public static function getCompositeElements(array $element) {
        return [
            'depending_content' =&gt; [
                '#markup' =&gt; 'content depending on earlier selections'
            ]
        ];
    }
}


How can I load the data insert to the form by the user in the earlier steps? $element doesn't contain anything helpful.
Finally I used the good old session.

My solution:

//mymodule.module
function mymodule_form_alter(array &amp;$form, FormStateInterface $form_state, $form_id) {
    $session = \Drupal::request()-&gt;getSession();
    $session-&gt;set('value_from_earlier_step', $form_state-&gt;get('value_from_earlier_step'));
}

//\src\Element\ExampleComposite.php
class ExampleComposite extends WebformCompositeBase {
    public static function getCompositeElements(array $element) {
        $session = \Drupal::request()-&gt;getSession();
        $expectations = $session-&gt;get('value_from_earlier_step');
    }
}