rehance-forms
Version:
Form utilities for React
38 lines (37 loc) • 1.15 kB
TypeScript
import * as React from "react";
import { FieldMap } from "./types";
import { ScopeContext, ListScopeContext } from "./ScopeContext";
export declare type CollectionScopeItemChildrenProps = {
scope: ScopeContext;
removeItem(): void;
};
export declare type CollectionScopeItemProps = {
parentScope: ListScopeContext;
initialValues?: FieldMap;
index: number;
children(scope: CollectionScopeItemChildrenProps): React.ReactNode;
onChange(index: number, values: FieldMap): void;
onRemove(index: number): void;
};
export declare class CollectionScopeItem extends React.Component<CollectionScopeItemProps> {
static defaultProps: Partial<CollectionScopeItemProps>;
private scope;
private unsubscribe;
constructor(props: CollectionScopeItemProps, context: any);
/**
* Unsubscribe from the field updates.
*/
componentWillUnmount(): void;
/**
* Handle field change on the scope.
*/
private handleScopeEvents;
/**
* Splice this element out of the parent array.
*/
private handleRemove;
/**
* Render the item scope.
*/
render(): JSX.Element;
}