Gutenberg Reusable Block of WordPress

This is the way it worked for me:

$post = get_post( $post_id );

if ( has_blocks( $post->post_content ) ) {
    $blocks = parse_blocks( $post->post_content );

    foreach ( $blocks as $block ) {
        if ( isset( $block['attrs']['id'] ) ) {
                echo $block['attrs']['id'];
        } elseif ( 'core/block' === $block['blockName'] ) {
            $block_content = parse_blocks( get_post( $block['attrs']['ref'] )->post_content );
            if ( isset( $block_content[0]['attrs']['id'] ) ) {
                echo $block_content[0]['attrs']['id'];
            }
        }
    }
}