Unable to render the components in Storybook

Created on 19 December 2022, over 1 year ago
Updated 15 November 2023, 7 months ago

Problem/Motivation

Cannot render the components in storybook and getting the error as attached in the screenshot while running the storybook.

Unable to find component
Check that the module or theme containing the component is enabled and matches the stories file name.

Steps to reproduce

Followed all the steps mentioned in https://git.drupalcode.org/project/cl_server/-/blob/1.x/docs/storybook.md

  1. I added one of the example components (my-cta) from the CL Components module to my Theme folder.
  2. Made sure theme path is added to main.js in .storybook folder
  3. Added my custom theme to drupalTheme and supportedDrupalThemes in preview.js
  4. Added valid permissions for anonymous user to access this endpoint

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

💬 Support request
Status

Active

Version

1.0

Component

Code

Created by

🇮🇳India sagarchauhan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇭Switzerland grumpy74 Geneva

    @dkosbob , @sagarchauhan, I had the same problem as you guys !

    Be careful to place your components folders and files under the "templates" folder of your theme (where you usually place your Drupal templates .html.twig). The plugin discovery manager only check in those locations apparently.

    Hope that helps !

    By the way, thank you @e0ipso for the great job on that modules ecosystem.

  • Status changed to Active about 1 year ago
  • 🇵🇹Portugal LuisPimentelLopes Lisbon 🇵🇹🇪🇺

    Hi, I also installed Storybook with Drupal integration with the reproduction steps and got the same issue but on the 2.0.0-alpha1.

    After a quick debug, it seems the controller is trying to create an instance of a plugin that doesn't exists.

      /**
       * Creates an instance.
       *
       * @throws \Drupal\sdc\Exception\ComponentNotFoundException
       *
       * @internal
       */
      public function createInstance($plugin_id, array $configuration = []): Component {
        $configuration['app_root'] = $this->appRoot;
        $configuration['enforce_schemas'] = $this->shouldEnforceSchemas(
          $this->definitions[$plugin_id] ?? []
        );
        try {
          $instance = parent::createInstance($plugin_id, $configuration);
          if (!$instance instanceof Component) {
            throw new ComponentNotFoundException(sprintf(
              'Unable to find component "%s" in the component repository.',
              $plugin_id,
            ));
          }
          return $instance;
        }
        catch (PluginException $e) {
          // Cast the PluginNotFound to a more specific exception.
          $message = sprintf(
            'Unable to find component "%s" in the component repository. [%s]',
            $plugin_id,
            $e->getMessage()
          );
          throw new ComponentNotFoundException($message, $e->getCode(), $e);
        }
      }
    
  • 🇩🇪Germany woldtwerk Stralibu

    got the same error. plugin definitions is always an empty array.

  • 🇺🇸United States markdorison

    We have experienced this issue when creating a new component but (so far) have been able to resolve it by rebuilding Drupal's cache.

Production build 0.69.0 2024