In theme functions.php you just check this… I think it’s may help you
In demo_menus
function I use your code it works pretty well… I don’t tell my code is good but I think this is best practice, we should try to best practice.
function demo_menus(){
$locations = array(
'top-menu' => __( 'Top Menu Location', 'text-domain' ),
'mobile-menu' => __( 'Mobile Menu Location', 'text-domain' )
);
register_nav_menus( $locations );
}
add_action( 'after_setup_theme', 'demo_menus' );