-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding FromNonStandardRednerProp demo
- Loading branch information
Showing
3 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import * as React from 'react'; | ||
import Step from '../Step'; | ||
import { | ||
fromNonStandardRenderProp, | ||
ChainableComponent | ||
} from '../../src/ChainableComponent'; | ||
|
||
type MyRenderPropProps = { | ||
foo: string; | ||
render?: (s: string) => React.ReactElement<any> | null; | ||
otherRender?: (n: number) => React.ReactElement<any> | null; | ||
}; | ||
|
||
const MyRenderProp = (props: MyRenderPropProps) => ( | ||
<div> | ||
{props.render | ||
? props.render('string value') | ||
: props.otherRender | ||
? props.otherRender(5) | ||
: null} | ||
</div> | ||
); | ||
|
||
const nonStandardStr = fromNonStandardRenderProp('render', MyRenderProp, { | ||
foo: 'asdf' | ||
}); | ||
const nonStandardNum = fromNonStandardRenderProp('otherRender', MyRenderProp, { | ||
foo: 'asdf' | ||
}); | ||
|
||
export const FromNonStandardRenderPropDemo = ChainableComponent.all([ | ||
nonStandardStr, | ||
nonStandardNum, | ||
nonStandardNum | ||
]).render(([foo, outer, inner]) => ( | ||
<div> | ||
{foo} | ||
<div> | ||
Outer: {outer} | ||
</div> | ||
<div> | ||
Inner: {inner} | ||
</div> | ||
</div> | ||
)); | ||
|
||
export default () => ( | ||
<Step title="FromNonStandardRenderPropDemo Demo"> | ||
<pre className="code-sample"> | ||
{`hmm | ||
`} | ||
</pre> | ||
{FromNonStandardRenderPropDemo} | ||
</Step> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters