OneOfType and ArrayOf try to get propType.value but only have propType.elements.
Uncaught TypeError: Cannot read property 'length' of undefined
at OneOfType (OneOfType.js:21)
The above error occurred in the <OneOfType> component:
in OneOfType (created by PrettyPropType)
in PrettyPropType (created by PropTable)
in td (created by glamorous(td))
in glamorous(td) (created by PropTable)
in tr (created by PropTable)
in tbody (created by PropTable)
in table (created by glamorous(table))
in glamorous(table) (created by PropTable)
in PropTable
in Unknown (created by Story)
in div (created by Story)
in div (created by Story)
in div (created by Story)
in div (created by Story)
in div (created by Story)
in Story
Use babel-plugin-flow-react-proptypes and union prop:
type Props = {
unionProp: 'one' | 'two',
};
class A extends Component<Props> {}
@storybook/react 3.3.3@storybook/addon-info 3.3.3react 16.2.0flow-bin 0.62.0babel-plugin-flow-react-proptypes 13.0.1can confirm. it also throws the same error without using babel-plugin-flow-react-proptypes though.
after some testing, i can boil it down to:
// component.js
// @flow
import React from 'react';
type Props = {
someValue?: 'one' | 'two' | 'three',
};
const SomeComponent = (props: Props) => <span>hey there</span>;
export default SomeComponent;
// mystory.js
import React from 'react';
import { storiesOf } from '@storybook/react';
import SomeComponent from './component';
storiesOf('Example', module).add('error', () => <SomeComponent />); // afforementioned exception
or, in other words, have a component file with flow typing and union type (if story and component are declared in the same module, it'll work fine), try to render a story with this component and it'll throw.
if the component is being wrapped within another component in the story file, it'll also work (probably because addon-info doesnt look for proptypes recursively?), i.e.:
// mystory.js
import React from 'react';
import { storiesOf } from '@storybook/react';
import SomeComponent from './component';
const Proxy = () => <SomeComponent />;
storiesOf('Example', module).add('error', () => <Proxy />); // no error. also, no prop types
Any progress on this issue ?
cool, thanks. Can i install somehow this info-addon from github master branch ?
@DimaRGB Unfortunately, I can't find a simple solution for this (there is an extremely complex one though)
So you probably need to wait until the weekend release
@Hypnosphi thanks :)
Most helpful comment
can confirm. it also throws the same error without using babel-plugin-flow-react-proptypes though.
after some testing, i can boil it down to:
or, in other words, have a component file with flow typing and union type (if story and component are declared in the same module, it'll work fine), try to render a story with this component and it'll throw.
if the component is being wrapped within another component in the story file, it'll also work (probably because addon-info doesnt look for proptypes recursively?), i.e.: