Skip to content
Anton Lebedev edited this page Nov 18, 2022 · 8 revisions

react-form - v1.0.0

Table of contents

Functions

Namespaces

Type Aliases

Interfaces

Functions

MaskedField

MaskedField<Name>(props): Element

A component for helping the user entering some text by configured mask.

Input pattern is determined by mask parameter. The user's text input is controlled by source parameter.

Type parameters

Name Type
Name extends string

Parameters

Name Type
props Props<Name>

Returns

Element


NumberField

NumberField<Name>(props): Element

Number field component

Type parameters

Name Type
Name extends string

Parameters

Name Type
props Props<Name>

Returns

Element


TextField

TextField<Name>(props): Element

Text field component

Type parameters

Name Type
Name extends string

Parameters

Name Type
props Props<Name>

Returns

Element


useForm

useForm<Data>(initialData): [Data, Dispatch<Exclude<{ [K in string | number | symbol]: Pick<Data, K> }[keyof Data], undefined>>]

Returns form data and a reducer action to update data key

const [data, setData] = useForm({
  name: 'John',
  surname: 'Doe'
});

return (
  <TextField value={data.name} onChange={setData}/>
);

Type parameters

Name Type
Data extends AbstractData = AbstractData

Parameters

Name Type
initialData Data

Returns

[Data, Dispatch<Exclude<{ [K in string | number | symbol]: Pick<Data, K> }[keyof Data], undefined>>]

Type Aliases

AbstractData

Ƭ AbstractData: Record<string, unknown>

Abstract form data interface