question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

addon-docs: No props for component in node_modules

See original GitHub issue

Describe the bug

I’ve created a mono repo which holds a component package and a cra+stroybook+ts project. The storybook project installs and imports the component package in its stories, but docs does not show the props of the component.

  • component package correctly builds dist and types
  • if I create a component inside the storybook project, it shows the props

Screenshots

set component to Component from my pacakge image

set component to Component inside the storybook project image

System:

    "typescript": "^4.0.2",
    "@storybook/react": "^6.0.16",
    "@storybook/preset-create-react-app": "^3.1.4",
    "@storybook/addon-actions": "^6.0.16",
    "@storybook/addon-links": "^6.0.15",
    "@storybook/addon-essentials": "^6.0.16",
    "@storybook/addons": "^6.0.16",

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:5
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
0xDingcommented, Dec 22, 2020

@shilman @zhaoyao91

It’s work for me as an alternative solution:

import AntButton from "antd/es/button"
import type { ButtonProps as AntdButtonProps } from "antd/es/button"
import React from 'react'

export interface ButtonProps extends AntdButtonProps{}
export const Button: React.FC<ButtonProps> = AntButton

and

 reactDocgenTypescriptOptions: {
      shouldExtractLiteralValuesFromEnum: true,
      propFilter: (prop) => ( prop.parent ? !/node_modules\/(?!ant).*/.test(prop.parent.fileName) : true),
    }
0reactions
cgreene-stcommented, Nov 29, 2022

For anyone else who stumbles across this issue and is in the situation where they’re having this problem with .js files in a linked package rather than .ts (and hence the fix above won’t work), adding your linked package’s path to the include array in the default rule makes things work (find the right rule either by index or matching against the test pattern):

config.module.rules[<whatever>].include.push(
    fs.realpathSync(path.resolve(path.join(__dirname, '..', 'node_modules', '<your_package>', '<etc>')))
)

I was in a similar situation to @sehv where I was trying to pass components from a package to <ArgsTable of={Component} /> (without Typescript just pure JS + PropTypes), and it still wasn’t working.

The solution above got me half the way there. Storybooks webpack config seems to exclude: /node_modules/ by default so what worked for me was to modify the exclude:

config.module.rules[<whatever>].exclude = {
  and: [path.resolve(path.join(__dirname, '..', 'node_modules'))],
  // Exclude the following from the exclusion
  not: [path.resolve(path.join(__dirname, '..', 'node_modules', '<your_package>', 'etc'))]
}

NOTE: It’s important for it to still ignore node_modules for everything else otherwise the build will grind to a halt.

Read more comments on GitHub >

github_iconTop Results From Across the Web

StoryBook addon-docs: "No props found for this component ...
I was able to solve this issue, basically I had misconfigured the webpack.config.js for StoryBook,
Read more >
DocsPage - Storybook - JS.ORG
Component parameter. Storybook uses the component key in the story file's default export to extract the component's description and props.
Read more >
@component-controls/storybook - npm
Start using @component-controls/storybook in your project by running `npm i @component-controls/storybook`. There are no other projects in ...
Read more >
Storybook Docs with mdx support and addon knobs - Medium
We have used Storybook to document our React component library for a while, ... name: '@storybook/addon-docs', // new addon for docs
Read more >
No props appearing for named function export with Addon ...
... various things to get the props to appear for my component library with no luck. This is using the 5.3.0-rc.0 version of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found