Storybook: Unable use components with hyphenated proptypes for aria attributes

Created on 3 Nov 2016  ·  3Comments  ·  Source: storybookjs/storybook

I upgraded from Storybook 2.24.0 to 2.29.3 today and Storybook no longer starts.

For me it breaks on our 3 components that use hyphenated proptypes for required aria attributes, such as this:

ExampleComponent.propTypes = {
  // Required because of accessibility
  'aria-label': PropTypes.string.isRequired,
};

If I remove those proptypes it works. I guess I could just use camelCase instead, but React supports this, and as I said, this used to work fine before the upgrade.

Here is a stacktrace:

ERROR in ./src/breadcrumb/Breadcrumb.jsx
Module parse failed: /Users/alexanbj/Documents/Jobb/Prosjekter/KF/common-frontend/packages/kf-ui/node_modules/babel-loader/index.js?{"babelrc":false,"cacheDirectory":"/Users/alexanbj/Documents/Jobb/Prosjekter/KF/common-frontend/packages/kf-ui/node_modules/.cache/react-storybook","presets":["/Users/alexanbj/Documents/Jobb/Prosjekter/KF/common-frontend/packages/kf-ui/node_modules/babel-preset-react-app/index.js"],"plugins":[["/Users/alexanbj/Documents/Jobb/Prosjekter/KF/common-frontend/packages/kf-ui/node_modules/babel-plugin-react-docgen/lib/index.js",{"DOC_GEN_COLLECTION_NAME":"STORYBOOK_REACT_CLASSES"}]]}!/Users/alexanbj/Documents/Jobb/Prosjekter/KF/common-frontend/packages/kf-ui/src/breadcrumb/Breadcrumb.jsx Unexpected token (89:8)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (89:8)
    at Parser.pp$4.raise (/Users/alexanbj/Documents/Jobb/Prosjekter/KF/common-frontend/packages/kf-ui/node_modules/acorn/dist/acorn.js:2221:15)
    at Parser.pp.unexpected (/Users/alexanbj/Documents/Jobb/Prosjekter/KF/common-frontend/packages/kf-ui/node_modules/acorn/dist/acorn.js:603:10)
    at Parser.pp.expect (/Users/alexanbj/Documents/Jobb/Prosjekter/KF/common-frontend/packages/kf-ui/node_modules/acorn/dist/acorn.js:597:28)
    at Parser.pp$3.parseObj (/Users/alexanbj/Documents/Jobb/Prosjekter/KF/common-frontend/packages/kf-ui/node_modules/acorn/dist/acorn.js:1973:16)
    at Parser.pp$3.parseExprAtom (/Users/alexanbj/Documents/Jobb/Prosjekter/KF/common-frontend/packages/kf-ui/node_modules/acorn/dist/acorn.js:1805:19)
    at Parser.pp$3.parseExprSubscripts (/Users/alexanbj/Documents/Jobb/Prosjekter/KF/common-frontend/packages/kf-ui/node_modules/acorn/dist/acorn.js:1715:21)
    at Parser.pp$3.parseMaybeUnary (/Users/alexanbj/Documents/Jobb/Prosjekter/KF/common-frontend/packages/kf-ui/node_modules/acorn/dist/acorn.js:1692:19)
    at Parser.pp$3.parseExprOps (/Users/alexanbj/Documents/Jobb/Prosjekter/KF/common-frontend/packages/kf-ui/node_modules/acorn/dist/acorn.js:1637:21)
    at Parser.pp$3.parseMaybeConditional (/Users/alexanbj/Documents/Jobb/Prosjekter/KF/common-frontend/packages/kf-ui/node_modules/acorn/dist/acorn.js:1620:21)
    at Parser.pp$3.parseMaybeAssign (/Users/alexanbj/Documents/Jobb/Prosjekter/KF/common-frontend/packages/kf-ui/node_modules/acorn/dist/acorn.js:1597:21)
 @ ./src/index.js 8:18-52
bug

Most helpful comment

Try the version 2.35.2.
I did a fix for this issue.

All 3 comments

I'm still getting this defect, would be great to resolve it.

Try the version 2.35.2.
I did a fix for this issue.

@arunoda You're my hero, thanks mate!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

p3k picture p3k  ·  61Comments

hckhanh picture hckhanh  ·  69Comments

tycho01 picture tycho01  ·  76Comments

dependencies[bot] picture dependencies[bot]  ·  142Comments

maraisr picture maraisr  ·  119Comments