How to check if current admin page is Gutenberg editor? [duplicate]

In 5.0 new function was introduced (docs):

WP_Screen::is_block_editor( bool $set = null )

which sets or returns whether the block editor is loading on the current screen.

So you can do that check using this code:

global $current_screen;
$current_screen = get_current_screen();
if ( method_exists($current_screen, 'is_block_editor') && $current_screen->is_block_editor() ) {
    // DO SOMETHING
}

You can also add to this condition

|| ( function_exists('is_gutenberg_page')) && is_gutenberg_page() )

to be compatible with older versions.