/
githubmr
/
facebook-react
Обзор
Документация
Войти
/
githubmr
/
facebook-react
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
v16.9.0
packages/shared/ReactLazyComponent.js
36 строк
869 B
Sebastian Markbåge
Unfork Lazy Component Branches (#13902)
20 окт 2018, 08:22
20 окт 2018, 08:22
95a313e
Код
Авторство
О чём код?
/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ export type Thenable<T, R> = { then(resolve: (T) => mixed, reject: (mixed) => mixed): R, }; export type LazyComponent<T> = { $$typeof: Symbol | number, _ctor: () => Thenable<{default: T}, mixed>, _status: 0 | 1 | 2, _result: any, }; type ResolvedLazyComponent<T> = { $$typeof: Symbol | number, _ctor: () => Thenable<{default: T}, mixed>, _status: 1, _result: any, }; export const Pending = 0; export const Resolved = 1; export const Rejected = 2; export function refineResolvedLazyComponent<T>( lazyComponent: LazyComponent<T>, ): ResolvedLazyComponent<T> | null { return lazyComponent._status === Resolved ? lazyComponent._result : null; }