Skip to content

Commit 8d1d15c

Browse files
committed
Simplify JsonSchemaform getComponent logic
1 parent e17a5f4 commit 8d1d15c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/core/json-schema-components.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class JsonSchemaForm extends Component {
3636

3737
let { type, format="" } = schema
3838

39-
let Comp = getComponent(`JsonSchema_${type}_${format}`) || getComponent(`JsonSchema_${type}`) || getComponent("JsonSchema_string")
39+
let Comp = format ? getComponent(`JsonSchema_${type}_${format}`) : getComponent(`JsonSchema_${type}`) || getComponent("JsonSchema_string")
4040
return <Comp { ...this.props } fn={fn} getComponent={getComponent} value={value} onChange={onChange} schema={schema}/>
4141
}
4242

@@ -68,19 +68,19 @@ export class JsonSchema_string extends Component {
6868
const isDisabled = schema["in"] === "formData" && !("FormData" in window)
6969
const Input = getComponent("Input")
7070
if (schema["type"] === "file") {
71-
return (<Input type="file"
72-
className={ errors.length ? "invalid" : ""}
71+
return (<Input type="file"
72+
className={ errors.length ? "invalid" : ""}
7373
title={ errors.length ? errors : ""}
74-
onChange={ this.onChange }
74+
onChange={ this.onChange }
7575
disabled={isDisabled}/>)
7676
}
7777
else {
78-
return (<Input type={ schema.format === "password" ? "password" : "text" }
79-
className={ errors.length ? "invalid" : ""}
78+
return (<Input type={ schema.format === "password" ? "password" : "text" }
79+
className={ errors.length ? "invalid" : ""}
8080
title={ errors.length ? errors : ""}
81-
value={value}
82-
placeholder={description}
83-
onChange={ this.onChange }
81+
value={value}
82+
placeholder={description}
83+
onChange={ this.onChange }
8484
disabled={isDisabled}/>)
8585
}
8686
}

0 commit comments

Comments
 (0)