-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
renderApplication() supports async initial render
Reviewed By: sahrens Differential Revision: D6339469 fbshipit-source-id: d832de936c50edcdc6953b72b5ad18ce1b652187
- Loading branch information
1 parent
ad89ea7
commit 1b22d49
Showing
1 changed file
with
23 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
bvaughn
Contributor
|
||
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; |
@bvaughn would be nice to have a public link here.