Unexpected error when trying to view revisions
You need to add a check and also no need to $node_info = Node::load as the node is already loaded. The first two lines inside the function are not even getting used, so I removed them.

function themename_preprocess_page(&amp;$variables) {  
  $node = \Drupal::routeMatch()-&gt;getParameter('node');
  if ($node instanceof \Drupal\node\NodeInterface) { // check it's a node
    if($node-&gt;hasField('field_component')) {
      $paragraph = $node-&gt;field_component-&gt;getValue();
      if($paragraph) {
        foreach ( $paragraph as $element ) {
          $p = \Drupal\paragraphs\Entity\Paragraph::load( $element['target_id'] );
        }
        $variables['hero_banner'] = $p;
      }
    }
  }
}