Skip to content

Commit

Permalink
renderApplication() supports async initial render
Browse files Browse the repository at this point in the history
Reviewed By: sahrens

Differential Revision: D6339469

fbshipit-source-id: d832de936c50edcdc6953b72b5ad18ce1b652187
  • Loading branch information
Brian Vaughn authored and facebook-github-bot committed Nov 17, 2017
1 parent ad89ea7 commit 1b22d49
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions Libraries/ReactNative/renderApplication.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Copy link
@chirag04

chirag04 Nov 18, 2017

Contributor

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

This comment has been minimized.

This comment has been minimized.

Copy link
@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.