UNPKG

1.5 kBTypeScriptView Raw
1import * as PropTypes from 'prop-types';
2import * as React from 'react';
3import { InputEventListener, InputTargetElement } from './types';
4interface EventStackProps {
5 /** An event name on which we will subscribe. */
6 name: string;
7 /** An event handler or array of event handlers. */
8 on: InputEventListener;
9 /** A name of pool. */
10 pool?: string;
11 /** A DOM element on which we will subscribe. */
12 target?: InputTargetElement;
13}
14/**
15 * This component exposes the EventStack API as public and provides a declarative way to manage it.
16 */
17export default class EventStack extends React.PureComponent<EventStackProps> {
18 static propTypes: {
19 /** An event name on which we will subscribe. */
20 name: PropTypes.Validator<string>;
21 /** An event handler or array of event handlers. */
22 on: PropTypes.Validator<((...args: any[]) => any) | (((...args: any[]) => any) | null)[]>;
23 /** A name of pool. */
24 pool: PropTypes.Requireable<string>;
25 /** A DOM element on which we will subscribe. */
26 target: PropTypes.Requireable<Object>;
27 };
28 static defaultProps: {
29 pool: string;
30 target: string;
31 };
32 componentDidMount(): void;
33 componentDidUpdate(prevProps: EventStackProps): void;
34 componentWillUnmount(): void;
35 subscribe(props: Readonly<EventStackProps>): void;
36 unsubscribe(props: Readonly<EventStackProps>): void;
37 render(): null;
38}
39export {};
40
\No newline at end of file