[@storybook/react] Array support for RenderFunction (#22529)

* Update storybook__react-tests.tsx

* Array support for RenderFunction

Follows React v16 update

* fix Jenkins build error

* fix tests error
This commit is contained in:
Anton Izmailov
2018-01-03 04:39:29 +03:00
committed by Mohamed Hegazy
parent e6b4f2333b
commit 85ffb53c7f
2 changed files with 5 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
// Type definitions for @storybook/react 3.0
// Project: https://github.com/storybooks/storybook
// Definitions by: Joscha Feth <https://github.com/joscha>
// Anton Izmailov <https://github.com/wapgear>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -9,7 +10,7 @@
import * as React from 'react';
export type Renderable = React.ComponentType | JSX.Element;
export type RenderFunction = () => Renderable;
export type RenderFunction = () => Renderable | Renderable[];
export type StoryDecorator = (story: RenderFunction, context: { kind: string, story: string }) => Renderable | null;

View File

@@ -6,7 +6,8 @@ const Decorator = (story: RenderFunction) => <div>{story()}</div>;
storiesOf('Welcome', module)
// local addDecorator
.addDecorator(Decorator)
.add('to Storybook', () => <div/>);
.add('to Storybook', () => <div/>)
.add('to Storybook as Array', () => [<div />, <div />]);
// global addDecorator
addDecorator(Decorator);
@@ -26,6 +27,7 @@ storiesOf<AnyAddon>('withAnyAddon', module)
.addWithSideEffect('custom story', () => <div/>)
.addWithSideEffect('more', () => <div/>)
.add('another story', () => <div/>)
.add('to Storybook as Array', () => [<div />, <div />])
.addWithSideEffect('even more', () => <div/>);
// configure