Pass initial props to WrapperComponent

Summary:
`renderApplication` receives the root component that we need to render and an optional wrapper component. There are cases where we want to use the initial props passed to the root component in the wrapper component as well (e.g.: to provide a specific context to the root component), so this adds modifies `AppContainer` to accept the initial props and inject them into the wrapper component.

Changelog: [General] [Added] - Modified `renderApplication` to forward `initialProps` to `WrapperComponent`

Reviewed By: fkgozali

Differential Revision: D21347486

fbshipit-source-id: 1c4f702a3875077630de1a44d3ac9ef2c80bc10c
This commit is contained in:
Rubén Norte authored and Facebook GitHub Bot committed 2020-05-05 04:54:56 -07:00
1 parent 0348953914
commit 4f5a092bf6
2 files changed
+3

No files matched your search

+2
View File
@@ -24,6 +24,7 @@ type Props = $ReadOnly<{|
children?: React.Node,
fabric?: boolean,
rootTag: number,
initialProps?: {...},
showArchitectureIndicator?: boolean,
WrapperComponent?: ?React.ComponentType<any>,
internal_excludeLogBox?: ?boolean,
@@ -119,6 +120,7 @@ class AppContainer extends React.Component<Props, State> {
if (Wrapper != null) {
innerView = (
<Wrapper
initialProps={this.props.initialProps}
fabric={this.props.fabric === true}
showArchitectureIndicator={
this.props.showArchitectureIndicator === true
@@ -41,6 +41,7 @@ function renderApplication<Props: Object>(
fabric={fabric}
showArchitectureIndicator={showArchitectureIndicator}
WrapperComponent={WrapperComponent}
initialProps={initialProps}
internal_excludeLogBox={isLogBox}>
<RootComponent {...initialProps} rootTag={rootTag} />
</AppContainer>