Merge pull request #24130 from dawnmist/storybook-addons-action/fix-decorateAction-definition

[@storybook/addon-actions]: Fix faulty decorateAction definition.
This commit is contained in:
Armando Aguirre
2018-03-07 12:37:19 -08:00
committed by GitHub
2 changed files with 19 additions and 1 deletions

View File

@@ -7,5 +7,5 @@
export type HandlerFunction = (...args: any[]) => undefined;
export type DecoratorFunction = (args: any[]) => any[];
export function decorateAction(decorators: DecoratorFunction[]): HandlerFunction;
export function decorateAction(decorators: DecoratorFunction[]): (name: string) => HandlerFunction;
export function action(name: string): HandlerFunction;

View File

@@ -19,3 +19,21 @@ storiesOf('Button', module)
Hello World!
</button>
));
interface CustomComponentProps {
id: string;
setValues(id: string, values: string[]): void;
}
class CustomComponent extends React.Component<CustomComponentProps> {
setSomeValues = () => {
this.props.setValues(this.props.id, ['one', 'two', 'three']);
}
render() {
return <button onClick={this.setSomeValues}>Set some values</button>;
}
}
storiesOf('CustomComponent', module)
.add('decorated custom action', () => (
<CustomComponent id="test" setValues={firstArgAction('set-values')} />
));