Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add initialProps property to RCTAppDelegate #35848

Conversation

jblarriviere
Copy link
Contributor

Summary

Hi there,

While upgrading to 0.71 we realised the RCTAppDelegate doesn't offer a way to set custom initProps that would depend on launchOptions.

This PR adds an initialProps property to the RCTAppDelegate. This would let us set this property based on launchOptions in our implementation of didFinishLaunchingWithOptions before calling [super didFinishLaunchingWithOptions]

Thanks !

Changelog

[IOS] [ADDED] - Add initialProps property to RCTAppDelegate

@facebook-github-bot
Copy link
Contributor

Hi @jblarriviere!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@github-actions
Copy link

github-actions bot commented Jan 16, 2023

Warnings
⚠️ 📋 Missing Test Plan - Can you add a Test Plan? To do so, add a "## Test Plan" section to your PR description. A Test Plan lets us know how these changes were tested.

Generated by 🚫 dangerJS against 93e2a94

@jblarriviere jblarriviere marked this pull request as draft January 16, 2023 17:31
@analysis-bot
Copy link

analysis-bot commented Jan 16, 2023

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,464,873 -660
android hermes armeabi-v7a 7,785,604 -676
android hermes x86 8,938,342 -671
android hermes x86_64 8,796,410 -673
android jsc arm64-v8a 9,651,262 +608
android jsc armeabi-v7a 8,385,729 +600
android jsc x86 9,713,458 +611
android jsc x86_64 10,190,641 +610

Base commit: e6d1ab9
Branch: main

@jblarriviere jblarriviere marked this pull request as ready for review January 16, 2023 18:05
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 16, 2023
Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me. I'm wondering how we can let users know about this. With this change only, it will be hidden in the AppDelegate library. 🤔
How do you feel about modifying the template adding something, like:

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.moduleName = @"HelloWorld";
+  // You can add your custom initial props in the dictionary below.
+  // They will be passed down to the ViewController used by React Native.
+  self.initialProps = @{}; 
  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

In this way we will also teach our users how to use this new property.

@facebook-github-bot
Copy link
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@jblarriviere
Copy link
Contributor Author

It looks good to me. I'm wondering how we can let users know about this. With this change only, it will be hidden in the AppDelegate library. 🤔 How do you feel about modifying the template adding something, like:

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.moduleName = @"HelloWorld";
+  // You can add your custom initial props in the dictionary below.
+  // They will be passed down to the ViewController used by React Native.
+  self.initialProps = @{}; 
  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

In this way we will also teach our users how to use this new property.

Thanks for your feedback. That sounds like a good way to let users know, I've added the comment you suggested .

@facebook-github-bot
Copy link
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jan 18, 2023
@facebook-github-bot
Copy link
Contributor

@cipolleschi merged this pull request in b314e6f.

kelset pushed a commit that referenced this pull request Jan 19, 2023
Summary:
Hi there,

While upgrading to 0.71 we realised the RCTAppDelegate doesn't offer a way to set custom `initProps` that would depend on `launchOptions`.

This PR adds an `initialProps` property to the RCTAppDelegate. This would let us set this property based on `launchOptions` in our implementation of `didFinishLaunchingWithOptions` before calling `[super didFinishLaunchingWithOptions]`

Thanks !

## Changelog

[IOS] [ADDED] - Add `initialProps` property to `RCTAppDelegate`

Pull Request resolved: #35848

Reviewed By: rshest

Differential Revision: D42543027

Pulled By: cipolleschi

fbshipit-source-id: 55374914890445f8193c12a06a943b7796edb457
@codemickey78
Copy link

Screenshot 2023-01-29 at 5 37 52 PM

I get this error in my AppDelegate file
Property 'initialProps' not found on object of type 'AppDelegate *'
When I comment it out it works buh some assets like fonts don't apply to the app.
Any solution for this issue

@jblarriviere
Copy link
Contributor Author

I get this error in my AppDelegate file Property 'initialProps' not found on object of type 'AppDelegate *' When I comment it out it works buh some assets like fonts don't apply to the app. Any solution for this issue

Are you using the 0.71.1 ? This PR is not available in previous versions

@cipolleschi
Copy link
Contributor

@codemickey78 if you are updating from a previous version of React Native, make sure that your AppDelegate extends RCTAppDelegat. If you followed the upgrade helper, you may have modified the AppDelegate.mm file but forgot to update the AppDelegate.h file.

OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
Summary:
Hi there,

While upgrading to 0.71 we realised the RCTAppDelegate doesn't offer a way to set custom `initProps` that would depend on `launchOptions`.

This PR adds an `initialProps` property to the RCTAppDelegate. This would let us set this property based on `launchOptions` in our implementation of `didFinishLaunchingWithOptions` before calling `[super didFinishLaunchingWithOptions]`

Thanks !

## Changelog

[IOS] [ADDED] - Add `initialProps` property to `RCTAppDelegate`

Pull Request resolved: facebook#35848

Reviewed By: rshest

Differential Revision: D42543027

Pulled By: cipolleschi

fbshipit-source-id: 55374914890445f8193c12a06a943b7796edb457
@cipolleschi cipolleschi mentioned this pull request Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants