Permalink
Browse files

renderApplication() supports async initial render

Reviewed By: sahrens

Differential Revision: D6339469

fbshipit-source-id: d832de936c50edcdc6953b72b5ad18ce1b652187
  • Loading branch information...
bvaughn authored and facebook-github-bot committed Nov 17, 2017
1 parent ad89ea7 commit 1b22d49ae8945680dee4fd01e3fbb78b1e443e01
Showing with 23 additions and 3 deletions.
  1. +23 −3 Libraries/ReactNative/renderApplication.js
@@ -30,12 +30,32 @@ function renderApplication<Props: Object>(
) {
invariant(rootTag, 'Expect to have a valid rootTag, instead got ', rootTag);
ReactNative.render(
let renderable = (
<AppContainer rootTag={rootTag} WrapperComponent={WrapperComponent}>
<RootComponent {...initialProps} rootTag={rootTag} />
</AppContainer>,
rootTag,
</AppContainer>
);
// If the root component is async, the user probably wants the initial render
// to be async also. To do this, wrap AppContainer with an async marker.
// For more info see https://fburl.com/tjpe0gpx

This comment has been minimized.

@chirag04

chirag04 Nov 18, 2017

Collaborator

@bvaughn would be nice to have a public link here.

This comment has been minimized.

This comment has been minimized.

@bvaughn

bvaughn Nov 20, 2017

Contributor

Fixed via PR #16892

if (
RootComponent.prototype != null &&
RootComponent.prototype.unstable_isAsyncReactComponent === true
) {
// $FlowFixMe This is not yet part of the official public API
class AppContainerAsyncWrapper extends React.unstable_AsyncComponent {
render() {
return this.props.children;
}
}
renderable = (
<AppContainerAsyncWrapper>{renderable}</AppContainerAsyncWrapper>
);
}
ReactNative.render(renderable, rootTag);
}
module.exports = renderApplication;

0 comments on commit 1b22d49

Please sign in to comment.