Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fixtures/flight-browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ <h1>Flight Example</h1>
}

function Shell({ data }) {
let model = data.readRoot();
let model = React.experimental_use(data);
return <div>
<Suspense fallback="...">
<h1>{model.title}</h1>
Expand Down
2 changes: 1 addition & 1 deletion fixtures/flight/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ReactServerDOMReader from 'react-server-dom-webpack';
let data = ReactServerDOMReader.createFromFetch(fetch('http://localhost:3001'));

function Content() {
return data.readRoot();
return React.experimental_use(data);
}

ReactDOM.render(
Expand Down
7 changes: 2 additions & 5 deletions packages/react-client/src/ReactFlightClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ Chunk.prototype.then = function<T>(
export type ResponseBase = {
_bundlerConfig: BundlerConfig,
_chunks: Map<number, SomeChunk<any>>,
readRoot<T>(): T,
...
};

Expand Down Expand Up @@ -177,10 +176,9 @@ function readChunk<T>(chunk: SomeChunk<T>): T {
}
}

function readRoot<T>(): T {
const response: Response = this;
export function getRoot<T>(response: Response): Thenable<T> {
const chunk = getChunk(response, 0);
return readChunk(chunk);
return (chunk: any);
}

function createPendingChunk<T>(response: Response): PendingChunk<T> {
Expand Down Expand Up @@ -541,7 +539,6 @@ export function createResponse(bundlerConfig: BundlerConfig): ResponseBase {
const response = {
_bundlerConfig: bundlerConfig,
_chunks: chunks,
readRoot: readRoot,
};
return response;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-client/src/ReactFlightClientStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,4 @@ export function createResponse(bundlerConfig: BundlerConfig): Response {
return response;
}

export {reportGlobalError, close} from './ReactFlightClient';
export {reportGlobalError, getRoot, close} from './ReactFlightClient';
Loading