/** * 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 type {BlockRenderFunction} from 'react/src/ReactBlock'; import type {ModuleReference} from './ReactFlightServerConfig'; import {REACT_SERVER_BLOCK_TYPE} from 'shared/ReactSymbols'; export type ServerBlockComponent = | [ Symbol | number, ModuleReference>, () => Data, ] | [Symbol | number, ModuleReference>]; opaque type ServerBlock: React$AbstractComponent< Props, null, > = React$AbstractComponent; export function serverBlock( moduleReference: ModuleReference>, loadData: () => Data, ): ServerBlock { const blockComponent: ServerBlockComponent = [ REACT_SERVER_BLOCK_TYPE, moduleReference, loadData, ]; // $FlowFixMe: Upstream BlockComponent to Flow as a valid Node. return blockComponent; } export function serverBlockNoData( moduleReference: ModuleReference>, ): ServerBlock { const blockComponent: ServerBlockComponent = [ REACT_SERVER_BLOCK_TYPE, moduleReference, ]; // $FlowFixMe: Upstream BlockComponent to Flow as a valid Node. return blockComponent; }