mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Some of our internal reconciler types have leaked into other packages. Usually, these types are treated as opaque; we don't read and write to its fields. This is good. However, the type is often passed back to a reconciler method. For example, React DOM creates a FiberRoot with `createContainer`, then passes that root to `updateContainer`. It doesn't do anything with the root except pass it through, but because `updateContainer` expects a full FiberRoot, React DOM is still coupled to all its fields. I don't know if there's an idiomatic way to handle this in Flow. Opaque types are simlar, but those only work within a single file. AFAIK, there's no way to use a package as the boundary for opaqueness. The immediate problem this presents is that the reconciler refactor will involve changes to our internal data structures. I don't want to have to fork every single package that happens to pass through a Fiber or FiberRoot, or access any one of its fields. So my current plan is to share the same Flow type across both forks. The shared type will be a superset of each implementation's type, e.g. Fiber will have both an `expirationTime` field and a `lanes` field. The implementations will diverge, but not the types. To do this, I lifted the type definitions into a separate module.
27 lines
610 B
JavaScript
27 lines
610 B
JavaScript
/**
|
|
* 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
|
|
*/
|
|
|
|
import ReactSharedInternals from 'shared/ReactSharedInternals';
|
|
|
|
const {ReactCurrentBatchConfig} = ReactSharedInternals;
|
|
|
|
export type SuspenseConfig = {|
|
|
timeoutMs: number,
|
|
busyDelayMs?: number,
|
|
busyMinDurationMs?: number,
|
|
|};
|
|
|
|
export type TimeoutConfig = {|
|
|
timeoutMs: number,
|
|
|};
|
|
|
|
export function requestCurrentSuspenseConfig(): null | SuspenseConfig {
|
|
return ReactCurrentBatchConfig.suspense;
|
|
}
|