export type Thenable<T, R> = {
then(resolve: (T) => mixed, reject: (mixed) => mixed): R,
};
// 接收一个可以返回 .then 函数的对象的函数(Promise,或者 like Promise)
export function lazy<T, R>(ctor: () => Thenable<T, R>): LazyComponent<T> {
// Lazy 类型的 React 元素
return {
$$typeof: REACT_LAZY_TYPE,
// 可以返回 .then 函数的对象的函数(Promise,或者 like Promise)
_ctor: ctor,
// React uses these fields to store the result.
// -1: 是未请求组件的状态
// 0: Pending
// 1: Resolved
// 2: Rejected
_status: -1,
// 返回的结果
_result: null,
};
}