File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
packages/react-noop-renderer/src Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * Copyright (c) Facebook, Inc. and its affiliates.
3+ *
4+ * This source code is licensed under the MIT license found in the
5+ * LICENSE file in the root directory of this source tree.
6+ *
7+ * @flow
8+ */
9+
10+ /**
11+ * This is a renderer of React that doesn't have a render target output.
12+ * It is useful to demonstrate the internals of the reconciler in isolation
13+ * and for testing semantics of reconciliation separate from the host
14+ * environment.
15+ */
16+
17+ import ReactFlightHooks from 'react-client/flight-hooks' ;
18+
19+ type Source = Array < string > ;
20+
21+ const { createResponse, processStringChunk, close} = ReactFlightClient ( {
22+ supportsBinaryStreams : false ,
23+ resolveModuleReference ( idx : string ) {
24+ return idx ;
25+ } ,
26+ preloadModule ( idx : string ) { } ,
27+ requireModule ( idx : string ) {
28+ return readModule ( idx ) ;
29+ } ,
30+ parseModel ( response : Response , json ) {
31+ return JSON . parse ( json , response . _fromJSON ) ;
32+ } ,
33+ } ) ;
34+
35+ function read < T > (source: Source): T {
36+ const response = createResponse ( source ) ;
37+ for ( let i = 0 ; i < source . length ; i ++ ) {
38+ processStringChunk ( response , source [ i ] , 0 ) ;
39+ }
40+ close ( response ) ;
41+ return response . readRoot ( ) ;
42+ }
43+
44+ export { read } ;
45+
You can’t perform that action at this time.
0 commit comments