Skip to content

Commit

Permalink
Pass initial props to WrapperComponent
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rubennorte authored and facebook-github-bot committed May 5, 2020
1 parent 0348953 commit 4f5a092
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Libraries/ReactNative/AppContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Props = $ReadOnly<{|
children?: React.Node,
fabric?: boolean,
rootTag: number,
initialProps?: {...},
showArchitectureIndicator?: boolean,
WrapperComponent?: ?React.ComponentType<any>,
internal_excludeLogBox?: ?boolean,
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Libraries/ReactNative/renderApplication.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function renderApplication<Props: Object>(
fabric={fabric}
showArchitectureIndicator={showArchitectureIndicator}
WrapperComponent={WrapperComponent}
initialProps={initialProps}
internal_excludeLogBox={isLogBox}>
<RootComponent {...initialProps} rootTag={rootTag} />
</AppContainer>
Expand Down

0 comments on commit 4f5a092

Please sign in to comment.