// SPDX-License-Identifier: AGPL-3.0
import * as React from 'react';
+import { memoize } from 'lodash/fp';
import {
isRequiredInput,
DirectoryCommandInputParameter,
component={DirectoryInputComponent}
format={format}
parse={parse}
- validate={[
- isRequiredInput(input)
- ? (directory?: Directory) => directory ? undefined : ERROR_MESSAGE
- : () => undefined,
- ]} />;
+ validate={getValidation(input)} />;
const format = (value?: Directory) => value ? value.basename : '';
basename: directory.name,
});
+const getValidation = memoize(
+ (input: DirectoryCommandInputParameter) => ([
+ isRequiredInput(input)
+ ? (directory?: Directory) => directory ? undefined : ERROR_MESSAGE
+ : () => undefined,
+ ])
+);
interface DirectoryInputComponentState {
open: boolean;