UNPKG

4.67 kBTypeScriptView Raw
1import * as React from 'react';
2import { Async } from './Async';
3import { EventGroup } from './EventGroup';
4import { IDisposable } from './IDisposable';
5import { ISettingsMap } from './warn/warn';
6import { IBaseProps } from './BaseComponent.types';
7/**
8 * BaseComponent class, which provides basic helpers for all components.
9 *
10 * @public
11 * {@docCategory BaseComponent}
12 *
13 * @deprecated Do not use. We are moving away from class component.
14 */
15export declare class BaseComponent<TProps extends IBaseProps = {}, TState = {}> extends React.Component<TProps, TState> {
16 /**
17 * @deprecated Use React's error boundaries instead.
18 */
19 static onError: (errorMessage?: string, ex?: any) => void;
20 /**
21 * Controls whether the componentRef prop will be resolved by this component instance. If you are
22 * implementing a passthrough (higher-order component), you would set this to false and pass through
23 * the props to the inner component, allowing it to resolve the componentRef.
24 */
25 protected _skipComponentRefResolution: boolean;
26 private __async;
27 private __events;
28 private __disposables;
29 private __resolves;
30 private __className;
31 /**
32 * BaseComponent constructor
33 * @param props - The props for the component.
34 * @param context - The context for the component.
35 */
36 constructor(props: TProps, context?: any);
37 /**
38 * When the component receives props, make sure the componentRef is updated.
39 */
40 componentDidUpdate(prevProps: TProps, prevState: TState): void;
41 /**
42 * When the component has mounted, update the componentRef.
43 */
44 componentDidMount(): void;
45 /**
46 * If we have disposables, dispose them automatically on unmount.
47 */
48 componentWillUnmount(): void;
49 /**
50 * Gets the object's class name.
51 */
52 readonly className: string;
53 /**
54 * Allows subclasses to push things to this._disposables to be auto disposed.
55 */
56 protected readonly _disposables: IDisposable[];
57 /**
58 * Gets the async instance associated with the component, created on demand. The async instance gives
59 * subclasses a way to execute setTimeout/setInterval async calls safely, where the callbacks
60 * will be cleared/ignored automatically after unmounting. The helpers within the async object also
61 * preserve the this pointer so that you don't need to "bind" the callbacks.
62 */
63 protected readonly _async: Async;
64 /**
65 * Gets the event group instance assocaited with the component, created on demand. The event instance
66 * provides on/off methods for listening to DOM (or regular javascript object) events. The event callbacks
67 * will be automatically disconnected after unmounting. The helpers within the events object also
68 * preserve the this reference so that you don't need to "bind" the callbacks.
69 */
70 protected readonly _events: EventGroup;
71 /**
72 * Helper to return a memoized ref resolver function.
73 * @param refName - Name of the member to assign the ref to.
74 * @returns A function instance keyed from the given refname.
75 * @deprecated Use `createRef` from React.createRef.
76 */
77 protected _resolveRef(refName: string): (ref: React.ReactNode) => React.ReactNode;
78 /**
79 * Updates the componentRef (by calling it with "this" when necessary.)
80 */
81 protected _updateComponentRef(currentProps: IBaseProps, newProps?: IBaseProps): void;
82 /**
83 * Warns when a deprecated props are being used.
84 *
85 * @param deprecationMap - The map of deprecations, where key is the prop name and the value is
86 * either null or a replacement prop name.
87 */
88 protected _warnDeprecations(deprecationMap: ISettingsMap<TProps>): void;
89 /**
90 * Warns when props which are mutually exclusive with each other are both used.
91 *
92 * @param mutuallyExclusiveMap - The map of mutually exclusive props.
93 */
94 protected _warnMutuallyExclusive(mutuallyExclusiveMap: ISettingsMap<TProps>): void;
95 /**
96 * Warns when props are required if a condition is met.
97 *
98 * @param requiredProps - The name of the props that are required when the condition is met.
99 * @param conditionalPropName - The name of the prop that the condition is based on.
100 * @param condition - Whether the condition is met.
101 */
102 protected _warnConditionallyRequiredProps(requiredProps: string[], conditionalPropName: string, condition: boolean): void;
103 private _setComponentRef;
104}
105/**
106 * Simple constant function for returning null, used to render empty templates in JSX.
107 *
108 * @public
109 */
110export declare function nullRender(): JSX.Element | null;