ghost-portal/packages/react-hooks/src/useNonEmptyString.ts
2021-01-03 11:33:39 +01:00

12 lines
367 B
TypeScript

// Copyright 2017-2021 @polkadot/react-hooks authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { FormField, useFormField } from './useFormField';
export function useNonEmptyString (initialValue = ''): FormField<string> {
return useFormField(
initialValue,
(value?: string | null): boolean => (value && value.length > 0) || false
);
}