-
Notifications
You must be signed in to change notification settings - Fork 24.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: This diff adds a way for the codegen to handle view configs with non-standard top event names by adding a `paperTopLevelNameDeprecated` field to events in the schema. ## The problem The problem this is solving is that Android host components build their own options for event settings in the view config. So instead of enforcing `onChange` to use the top level event name `topChange` like iOS does, Android can use `change` or `forbarChange` or anything the person adding the component wanted at the time: ``` // Expected topChange: { registrationName: 'onChange', }, // Android bringBackStargateYouCowards: { registrationName: 'onChange', }, ``` This is possible because of the way Android builds these settings ``` // On iOS, notice that there's no option to change the top level name: RCT_EXPORT_VIEW_PROPERTY(onChange, RCTDirectEventBlock); // On Android, you provide the top level event name Override public Map getExportedCustomDirectEventTypeConstants() { return MapBuilder.of( "bringBackStargateYouCowards", MapBuilder.of("registrationName", "onChange")); } ``` Since the codegen does not allow us to specify the top level event name (similar to iOS), we don't have a way to customize the names to support android ## The solution To fix this, we're adding an extra option the event flow types: ``` onBubblingChange: (event: BubblingEvent<Event, 'customBubblingName'>) => void, onDirectChange: (event: DirectEvent<Event, 'customDirectName'>) => void, ``` These will register **both** top level names in the view config: ``` { directEventTypes: { // Notice the same registration name is configured for different top level events topChange: { registrationName: 'onChange', }, bringBackStargateYouCowards: { registrationName: 'onChange', }, } } ``` This means when either `topChange` or `bringBackStargateYouCowards` fires it will call the onChange listener. **This gives us the flexibility to rename the native event name without breaking backwards compatibility.** Old apps will work when `bringBackStargateYouCowards` is fired, and new apps with an update will work when `topChange` fires. Note: only the correct name will be generated for Fabric so technically we don't even really need to migrate the paper names and this prop can be deleted when paper is gone. Reviewed By: cpojer Differential Revision: D16042065 fbshipit-source-id: 40d076b43ffbbfc6c65c3c19de481d922a2add62
- Loading branch information
1 parent
1468625
commit 9a84970
Showing
17 changed files
with
2,086 additions
and
200 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
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
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
Oops, something went wrong.