react-params prioritize displayName (#1846)

* constructor index bug

* Contract fixes

* lint

* console

* console

* prioritize displayName params

* linting
This commit is contained in:
Keith Ingram 2019-11-06 12:25:33 +01:00 committed by GitHub
parent 8cd84e8f6b
commit afdc1a243a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -72,7 +72,11 @@ const components: ComponentMap = ([
export default function findComponent (def: TypeDef, overrides: ComponentMap = {}): React.ComponentType<Props> {
const findOne = (type: string): React.ComponentType<Props> | null =>
overrides[type] || components[type];
const type = (({ info, sub, type }: TypeDef): string => {
const type = (({ displayName, info, sub, type }: TypeDef): string => {
if (displayName) {
return displayName;
}
switch (info) {
case TypeDefInfo.Compact:
return (sub as TypeDef).type;

View File

@ -27,8 +27,8 @@ function Param ({ className, defaultValue, isDisabled, isOptional, name, onChang
}
const label = isUndefined(name)
? type.type
: `${name}: ${type.type}`;
? (type.displayName || type.type)
: `${name}: ${type.displayName || type.type}`;
return isOptional
? (