Merge pull request #14471 from vsaarinen/recompose-optional-second-branch-parameter

recompose: Third parameter to branch() should be optional
This commit is contained in:
Arthur Ozga
2017-02-06 11:25:59 -08:00
committed by GitHub
2 changed files with 8 additions and 2 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
// Type definitions for Recompose v0.20.2
// Type definitions for Recompose v0.20.3
// Project: https://github.com/acdlite/recompose
// Definitions by: Iskander Sierra <https://github.com/iskandersierra>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -103,7 +103,7 @@ declare module 'recompose' {
export function branch<TOutter>(
test: predicate<TOutter>,
trueEnhancer: InferableComponentEnhancer,
falseEnhancer: InferableComponentEnhancer
falseEnhancer?: InferableComponentEnhancer
): ComponentEnhancer<any, TOutter>;
// renderComponent: https://github.com/acdlite/recompose/blob/master/docs/API.md#renderComponent
+6
View File
@@ -148,13 +148,19 @@ function testBranch() {
const innerComponent: React.StatelessComponent<InnerProps> = (props: InnerProps) =>
<div onClick={() => props.update()}>{props.count}</div>;
const innerComponent2 = () => <div>Hello</div>;
const enhancer = branch(
(props: OutterProps) => props.toggled,
withState("count", "update", 0),
withState("count", "update", 100)
);
const enhancer2 = branch(
(props: OutterProps) => props.toggled,
renderComponent(innerComponent),
)
const enhanced: React.ComponentClass<OutterProps> = enhancer(innerComponent);
const enhanced2: React.ComponentClass<OutterProps> = enhancer2(innerComponent);
}
function testRenderComponent() {