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.

Error in addon-docs prop table when using HOC

See original GitHub issue

Describe the bug When using HOCs, the PropTypes aren’t correctly displayed in the addon-docs prop table.
Instead, the following error is displayed:

Cannot read property ‘classes’ of undefined

To Reproduce Steps to reproduce the behavior:

  1. Create an HOC.
  2. Create a story for this component

Expected behavior The prop table should be filled with the component’s proptypes.

Screenshots Error

Code snippets

class Alert extends React.Component { ... }
Alert.propTypes = {
  variant: PropTypes.string,
  dismissible: PropTypes.bool,
  icon: PropTypes.elementType,
  classes: PropTypes.object.isRequired
};
Alert.defaultProps = {
  variant: 'primary',
  dismissible: false,
};

export default withStyles(theme => ({
  alert: props => ({
    backgroundColor: theme.palette[props.variant].main
  }),
  message: {
    display: 'flex',
    alignItems: 'center',
  },
  icon: {
    marginRight: theme.spacing(2),
  }
}))(Alert);

System:

System:
    OS: Windows 10 10.0.18362
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  Binaries:
    Node: 10.16.0 - C:\Program Files\nodejs\node.EXE      
    npm: 6.10.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 44.18362.449.0

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:7
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

23reactions
gitnarqtcommented, Jan 14, 2021

Any update on this issue? It just doesn’t make sense to add unnecessary exports to the code just to document it properly 🤷🏻‍♂️

8reactions
shilmancommented, Dec 24, 2019

@gforrest-bw absolutely. hopefully we can address this in january as a high-priority bug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Storybook Docs with mdx support and addon knobs - Medium
In the component's mdx page, I give examples of the component. Prop Tables. Prop tables on the documentation pages are much improved. These...
Read more >
@storybook/react-native - npm
Fixes issue #601 where it throws error when introduce a propType with a hypen. Add a fix to babel-plugin-react-docgen to fix this issue....
Read more >
@storybook/react | Yarn - Package Manager
Storybook for React: Develop React Component in isolation with Hot Reloading. storybook. readme. Storybook. Build bulletproof UI components faster. Build Status ...
Read more >
How to enable prop-types in production for a React Storybook ...
When running the storybook locally, everything works perfectly. The prop-types are detected and this table is generated. SpinningLoader.
Read more >
uselocation cannot read properties of undefined (reading 'location ...
To get the current location use the useLocation hook. ... Login in withRouter HOC to make sure `router` prop is available export default...
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