Merge pull request #19499 from antonvasin/addon-links-linkto-function

Allow to use function for linkTo
This commit is contained in:
Nathan Shively-Sanders
2017-09-05 15:37:17 -07:00
committed by GitHub
2 changed files with 6 additions and 1 deletions

View File

@@ -6,4 +6,6 @@
import * as React from 'react';
export function linkTo<T>(book: string, kind?: string): React.MouseEventHandler<T>;
export type LinkToFunction = (...args: any[]) => string;
export function linkTo<T>(book: string | LinkToFunction, kind?: string | LinkToFunction): React.MouseEventHandler<T>;

View File

@@ -8,4 +8,7 @@ storiesOf('Button', module)
))
.add('Second', () => (
<button onClick={linkTo('Button', 'First')}>Go to "First"</button>
))
.add('With function', () => (
<button onClick={linkTo((arg1, arg2) => 'Button', () => 'First')}>Go to "First"</button>
));