diff --git a/components/home/home.tsx b/components/home/home.tsx index 147f1745..3b282a55 100644 --- a/components/home/home.tsx +++ b/components/home/home.tsx @@ -45,7 +45,9 @@ export default function Home() { message: 'Drag file here', isError: false, }) - const [tempExperiment, setTempExperiment] = useState() + const [tempExperiment, setTempExperiment] = useState< + ExperimentType | undefined + >() const saveExperimentLocally = useCallback( (experiment: ExperimentType) => { @@ -79,7 +81,7 @@ export default function Home() { } const load = (reader: FileReader) => { - const binaryResult: string | ArrayBuffer = reader.result + const binaryResult: string | ArrayBuffer | null = reader.result try { const experiment: ExperimentType = JSON.parse(binaryResult as string) if (experiment.id === undefined) { @@ -125,7 +127,7 @@ export default function Home() { const getExperimentName = (key: string) => { try { - const json: any = JSON.parse(localStorage.getItem(key)) + const json: any = JSON.parse(localStorage.getItem(key) ?? '') const experiment: ExperimentType = json.experiment return !isEmpty(experiment.info.name) ? experiment.info.name : '-' } catch (e) { @@ -151,12 +153,12 @@ export default function Home() { } const handleOverwriteDialog = () => { - saveExperimentLocally(tempExperiment) + tempExperiment && saveExperimentLocally(tempExperiment) setTempExperiment(undefined) } const handleCreateDialog = () => { - saveExperimentLocally({ ...tempExperiment, id: uuid() }) + tempExperiment && saveExperimentLocally({ ...tempExperiment, id: uuid() }) setTempExperiment(undefined) } diff --git a/components/input-model/categorical-variable.tsx b/components/input-model/categorical-variable.tsx index e2b7c625..df8920d8 100644 --- a/components/input-model/categorical-variable.tsx +++ b/components/input-model/categorical-variable.tsx @@ -21,7 +21,7 @@ type CategoricalVariableProps = { export default function CategoricalVariable(props: CategoricalVariableProps) { const classes = useStyles() const { isDisabled, onAdded } = props - const [options, setOptions] = useState([]) + const [options, setOptions] = useState([]) const { register, handleSubmit, reset, formState, setError, clearErrors } = useForm() const isOptionsValid = useCallback(() => { @@ -57,7 +57,6 @@ export default function CategoricalVariable(props: CategoricalVariableProps) { <>