[react-albus] Add function-as-children as an alternative to the render-prop to Step

This commit is contained in:
Conrad Reuter
2018-09-21 12:51:40 +02:00
parent fdb583ed26
commit d23748c6c4
2 changed files with 14 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
// Type definitions for react-albus 2.0
// Project: https://github.com/americanexpress/react-albus#readme
// Definitions by: Sindre Seppola <https://github.com/sseppola>
// Conrad Reuter <https://github.com/conradreuter>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
@@ -34,5 +35,7 @@ export const Steps: React.ComponentType<{
export const Step: React.ComponentType<{
id: string;
render: (wizard: WizardContext) => React.ReactNode;
}>;
} & (
| { render?: (wizard: WizardContext) => React.ReactNode; }
| { children: (wizard: WizardContext) => React.ReactNode; }
)>;

View File

@@ -37,15 +37,20 @@ const Example = () => (
</div>
)}
/>
<Step
id="dumbledore"
render={({ previous }) => (
<Step id="dumbledore">
{({ previous, next }) => (
<div>
<h1>Dumbledore</h1>
<button onClick={previous}>Previous</button>
<button onClick={next}>Next</button>
</div>
)}
/>
</Step>
<Step id="harry">
<div>
<h1>Harry</h1>
</div>
</Step>
</Steps>
)}
/>