From 974fab72844d51314f726316d25161e1a8c14cc1 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 15 Feb 2018 23:54:36 -0700 Subject: replace repeated conditionals with variable --- .../ts/pages/documentation/method_signature.tsx | 35 +++++++++++----------- 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'packages/website/ts/pages/documentation') diff --git a/packages/website/ts/pages/documentation/method_signature.tsx b/packages/website/ts/pages/documentation/method_signature.tsx index a24d35924..f94524b48 100644 --- a/packages/website/ts/pages/documentation/method_signature.tsx +++ b/packages/website/ts/pages/documentation/method_signature.tsx @@ -24,27 +24,26 @@ export const MethodSignature: React.SFC = (props: MethodSi const sectionName = constants.TYPES_SECTION_NAME; const parameters = renderParameters(props.method, props.docsInfo, sectionName, props.typeDefinitionByName); const paramStringArray: any[] = []; + const hasMoreThenTwoParams = parameters.length > 2; _.each(parameters, (param: React.ReactNode, i: number) => { - const finalParam = - parameters.length > 2 ? ( - - {param} - - ) : ( - param - ); + const finalParam = hasMoreThenTwoParams ? ( + + {param} + + ) : ( + param + ); paramStringArray.push(finalParam); - const comma = - parameters.length > 2 ? ( - - ,
-
- ) : ( - ', ' - ); + const comma = hasMoreThenTwoParams ? ( + + ,
+
+ ) : ( + ', ' + ); paramStringArray.push(comma); }); - if (parameters.length <= 2) { + if (!hasMoreThenTwoParams) { paramStringArray.pop(); } const methodName = props.shouldHideMethodName ? '' : props.method.name; @@ -55,7 +54,7 @@ export const MethodSignature: React.SFC = (props: MethodSi {props.method.callPath} {methodName} - {typeParameterIfExists}({parameters.length > 2 &&
} + {typeParameterIfExists}({hasMoreThenTwoParams &&
} {paramStringArray}) {props.method.returnType && ( -- cgit v1.2.3