-
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.
Generate RCTThirdPartyComponentProvider (#47518)
Summary: Pull Request resolved: #47518 This change reintroduce the generation of the `RCTThirdPartyComponentProvider` but in the right place and with the right patterns. 1. We are generating it in the user space, not in the node_modules (fixes the circular dependency) 2. We are not using weak function signature that have to be implicitly linked to some symbols found during compilation The change needs to crawl the folder to retrieve the information it needs. We need to implement it this way not to be breaking with respect of the current implementation. The assumption is that components have a function in their `.mm` file with this shape: ```objc Class<RCTComponentViewProtocol> <componentName>Cls(void) { return <ComponentViewClass>.class; } ``` I verified on GH that all the libraries out there follow this pattern. A better approach will let library owner to specify the association of `componentName, componentClass` in the `codegenConfig`. We will implement that as the next step and we will support both for some versions for backward compatibility. ## Changelog [iOS][Changed] - Change how components automatically register Reviewed By: dmytrorykun Differential Revision: D65614347 fbshipit-source-id: a378b8bc31c1ab3d49552f2f6a4c86c3b578746b
- Loading branch information
1 parent
60b9d3d
commit 8becc25
Showing
7 changed files
with
184 additions
and
24 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
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
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
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
16 changes: 16 additions & 0 deletions
16
packages/react-native/scripts/codegen/templates/RCTThirdPartyComponentsProviderH.template
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@protocol RCTComponentViewProtocol; | ||
|
||
@interface RCTThirdPartyComponentsProvider: NSObject | ||
|
||
+ (NSDictionary<NSString *, Class<RCTComponentViewProtocol>> *)thirdPartyFabricComponents; | ||
|
||
@end |
23 changes: 23 additions & 0 deletions
23
packages/react-native/scripts/codegen/templates/RCTThirdPartyComponentsProviderMM.template
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#import "RCTThirdPartyComponentsProvider.h" | ||
#import <React/RCTComponentViewProtocol.h> | ||
|
||
@implementation RCTThirdPartyComponentsProvider | ||
|
||
+ (NSDictionary<NSString *, Class<RCTComponentViewProtocol>> *)thirdPartyFabricComponents | ||
{ | ||
return @{ | ||
{thirdPartyComponentsMapping} | ||
}; | ||
} | ||
|
||
@end |
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