Site icon Hip-Hop Website Design and Development

Gutenberg: How to update associated Terms of Custom Taxonomy to Current Post

I have successfully created a custom Gutenberg block which can modify several meta data and native post data. Among other, I’ve built a dropdown with all the terms of a custom taxonomy (with show_in_rest set to TRUE). The dropdown works well, but how can I save the selection back to the post?

<SelectControl
    label="My Dropdown"
    options={ options }
    value={ value }
    onChange={ v => update( v ) }
/>

Whenever I select another value in the dropdown, the following function is executed:

const update = ( t ) => {
    // The selected option can have a value of zero (= assign no term)
    const ids = [];
    if ( t.value ) {
        ids.push( t.value );
    }
    
    // the following line does not work
    // editEntityRecord( 'postType', 'my_custom_post_type', post.id, { 'my_custom_taxonomy': [ t.value ] } );

    // nor does this line
    editPost( {
        my_custom_taxonomy: [ t.value ]
    });
    // ... updating value in the state in order to make the dropdown work 
}

I am not even sure if I should use editPost or editEntityRecord.

How can I save the new selected term id to the post?