diff options
author | Fabio Berger <me@fabioberger.com> | 2018-09-28 06:00:01 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-09-28 06:00:01 +0800 |
commit | ac878d8fdbace787c7ffbc0fe68dd404d72452e3 (patch) | |
tree | 8833cb9f33f2b8beb81a956148b804b5cc5f4f72 /packages/react-docs/src | |
parent | ac04dbf7e4f04ae4e0a6e9cce5232339597493ed (diff) | |
download | dexon-sol-tools-ac878d8fdbace787c7ffbc0fe68dd404d72452e3.tar dexon-sol-tools-ac878d8fdbace787c7ffbc0fe68dd404d72452e3.tar.gz dexon-sol-tools-ac878d8fdbace787c7ffbc0fe68dd404d72452e3.tar.bz2 dexon-sol-tools-ac878d8fdbace787c7ffbc0fe68dd404d72452e3.tar.lz dexon-sol-tools-ac878d8fdbace787c7ffbc0fe68dd404d72452e3.tar.xz dexon-sol-tools-ac878d8fdbace787c7ffbc0fe68dd404d72452e3.tar.zst dexon-sol-tools-ac878d8fdbace787c7ffbc0fe68dd404d72452e3.zip |
Improve keys
Diffstat (limited to 'packages/react-docs/src')
-rw-r--r-- | packages/react-docs/src/components/signature.tsx | 6 | ||||
-rw-r--r-- | packages/react-docs/src/components/signature_block.tsx | 6 | ||||
-rw-r--r-- | packages/react-docs/src/components/type.tsx | 6 |
3 files changed, 10 insertions, 8 deletions
diff --git a/packages/react-docs/src/components/signature.tsx b/packages/react-docs/src/components/signature.tsx index 266bfe3dd..1f3dd0ee8 100644 --- a/packages/react-docs/src/components/signature.tsx +++ b/packages/react-docs/src/components/signature.tsx @@ -36,6 +36,7 @@ export const Signature: React.SFC<SignatureProps> = (props: SignatureProps) => { props.docsInfo, sectionName, props.isInPopover, + props.name, props.typeDefinitionByName, ); const paramStringArray: any[] = []; @@ -103,9 +104,10 @@ function renderParameters( docsInfo: DocsInfo, sectionName: string, isInPopover: boolean, + name: string, typeDefinitionByName?: TypeDefinitionByName, ): React.ReactNode[] { - const params = _.map(parameters, (p: Parameter) => { + const params = _.map(parameters, (p: Parameter, i: number) => { const isOptional = p.isOptional; const hasDefaultValue = !_.isUndefined(p.defaultValue); const type = ( @@ -121,7 +123,7 @@ function renderParameters( <span key={`param-${JSON.stringify(p.type)}-${name}-${i}`}> {!_.isEmpty(p.name) && ( <span> - {p.name} + {p.name} {isOptional && '?'}:{' '} </span> )} diff --git a/packages/react-docs/src/components/signature_block.tsx b/packages/react-docs/src/components/signature_block.tsx index fc4db10ad..1e3de3e58 100644 --- a/packages/react-docs/src/components/signature_block.tsx +++ b/packages/react-docs/src/components/signature_block.tsx @@ -124,12 +124,12 @@ export class SignatureBlock extends React.Component<SignatureBlockProps, Signatu </div> ); } - private _renderParameterDescriptions(parameters: Parameter[]): React.ReactNode { - const descriptions = _.map(parameters, parameter => { + private _renderParameterDescriptions(parameters: Parameter[], name: string): React.ReactNode { + const descriptions = _.map(parameters, (parameter: Parameter, i: number) => { const isOptional = parameter.isOptional; return ( <div - key={`param-description-${parameter.name}`} + key={`param-description-${parameter.name}-${name}-${i}`} className="flex pb1 mb2" style={{ borderBottom: '1px solid #f0f4f7' }} > diff --git a/packages/react-docs/src/components/type.tsx b/packages/react-docs/src/components/type.tsx index b7a94483e..8ff2fa3cc 100644 --- a/packages/react-docs/src/components/type.tsx +++ b/packages/react-docs/src/components/type.tsx @@ -169,10 +169,10 @@ export const Type: React.SFC<TypeProps> = (props: TypeProps): any => { break; case TypeDocTypes.Tuple: - const tupleTypes = _.map(type.tupleElements, t => { + const tupleTypes = _.map(type.tupleElements, (t, i) => { return ( <Type - key={`type-tuple-${t.name}-${t.typeDocType}`} + key={`type-tuple-${t.name}-${t.typeDocType}-${i}`} type={t} sectionName={props.sectionName} typeDefinitionByName={props.typeDefinitionByName} @@ -222,7 +222,7 @@ export const Type: React.SFC<TypeProps> = (props: TypeProps): any => { const id = Math.random().toString(); const typeDefinitionAnchorId = isExportedClassReference ? props.type.name - : `${constants.TYPES_SECTION_NAME}-${typeName}`; + : `${props.docsInfo.typeSectionName}-${typeName}`; typeName = ( <ScrollLink to={typeDefinitionAnchorId} |