Skip to content

Commit c778ea0

Browse files
committed
guarding against null validation_contains field
1 parent 9a232a8 commit c778ea0

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

site/src/components/ParameterInput/ParameterInput.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
12
import FormControlLabel from "@material-ui/core/FormControlLabel"
23
import Radio from "@material-ui/core/Radio"
34
import RadioGroup from "@material-ui/core/RadioGroup"
@@ -29,23 +30,24 @@ export const ParameterInput: FC<ParameterInputProps> = ({ disabled, onChange, sc
2930
}
3031

3132
const ParameterField: React.FC<ParameterInputProps> = ({ disabled, onChange, schema }) => {
32-
if (schema.validation_contains.length > 0) {
33+
if (schema.validation_contains && schema.validation_contains.length > 0) {
3334
return (
3435
<RadioGroup
3536
defaultValue={schema.default_source_value}
3637
onChange={(event) => {
3738
onChange(event.target.value)
3839
}}
3940
>
40-
{schema.validation_contains.map((item) => (
41-
<FormControlLabel
42-
disabled={disabled}
43-
key={item}
44-
value={item}
45-
control={<Radio color="primary" size="small" disableRipple />}
46-
label={item}
47-
/>
48-
))}
41+
{schema.validation_contains &&
42+
schema.validation_contains.map((item) => (
43+
<FormControlLabel
44+
disabled={disabled}
45+
key={item}
46+
value={item}
47+
control={<Radio color="primary" size="small" disableRipple />}
48+
label={item}
49+
/>
50+
))}
4951
</RadioGroup>
5052
)
5153
}

0 commit comments

Comments
 (0)