Skip to content

Commit 06a08bc

Browse files
philIipOlimpiaZurek
authored andcommitted
hook up offscreen api to runApplication
Summary: [Changelog]: Internal integrate the offscreen component when we render an application that is configured to do so Reviewed By: rubennorte Differential Revision: D39458472 fbshipit-source-id: 9bd492ca258723cb9cf0b7e4f6c9b0005554e91e
1 parent 413a5ad commit 06a08bc

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Libraries/ReactNative/renderApplication.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
*/
1010

1111
import type {IPerformanceLogger} from '../Utilities/createPerformanceLogger';
12-
import type {DisplayModeType} from './DisplayMode';
1312

1413
import GlobalPerformanceLogger from '../Utilities/GlobalPerformanceLogger';
1514
import PerformanceLoggerContext from '../Utilities/PerformanceLoggerContext';
1615
import AppContainer from './AppContainer';
16+
import DisplayMode, {type DisplayModeType} from './DisplayMode';
1717
import getCachedComponentWithDebugName from './getCachedComponentWithDebugName';
1818
import * as Renderer from './RendererProxy';
1919
import invariant from 'invariant';
@@ -22,6 +22,11 @@ import * as React from 'react';
2222
// require BackHandler so it sets the default handler that exits the app if no listeners respond
2323
import '../Utilities/BackHandler';
2424

25+
type OffscreenType = React.AbstractComponent<{
26+
mode: 'visible' | 'hidden',
27+
children: React.Node,
28+
}>;
29+
2530
export default function renderApplication<Props: Object>(
2631
RootComponent: React.ComponentType<Props>,
2732
initialProps: Props,
@@ -34,6 +39,7 @@ export default function renderApplication<Props: Object>(
3439
debugName?: string,
3540
displayMode?: ?DisplayModeType,
3641
useConcurrentRoot?: boolean,
42+
useOffscreen?: boolean,
3743
) {
3844
invariant(rootTag, 'Expect to have a valid rootTag, instead got ', rootTag);
3945

@@ -64,6 +70,19 @@ export default function renderApplication<Props: Object>(
6470
);
6571
}
6672

73+
if (useOffscreen && displayMode != null) {
74+
// $FlowFixMe[incompatible-type]
75+
// $FlowFixMe[prop-missing]
76+
const Offscreen: OffscreenType = React.unstable_Offscreen;
77+
78+
renderable = (
79+
<Offscreen
80+
mode={displayMode === DisplayMode.VISIBLE ? 'visible' : 'hidden'}>
81+
{renderable}
82+
</Offscreen>
83+
);
84+
}
85+
6786
performanceLogger.startTimespan('renderApplication_React_render');
6887
performanceLogger.setExtra(
6988
'usedReactConcurrentRoot',

0 commit comments

Comments
 (0)