Push ReactContext logic in derived classes#44226
Closed
RSNara wants to merge 1 commit intofacebook:mainfrom
Closed
Push ReactContext logic in derived classes#44226RSNara wants to merge 1 commit intofacebook:mainfrom
RSNara wants to merge 1 commit intofacebook:mainfrom
Conversation
Base commit: e67d556 |
d443ee2 to
b5c7d01
Compare
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D56064036 |
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D56064036 |
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D56064036 |
1 similar comment
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D56064036 |
Summary: Changelog: [Android][Removed] Delete ReactContext.initializeWithInstance(). ReactContext now no longer contains legacy react instance methods. Please use BridgeReactInstance instead. Yet another attempt to land this (last one was D55964787). Copy-pasting below the amazing summary from RSNara. ## Context Prior, ReactContext used to implement bridge logic. For bridgeless mode, we created BridgelessReactContext < ReactContext ## Problem This could lead to failures: we could call bridge methods in bridgeless mode. ## Changes Primary change: - Make all the react instance methods inside ReactContext abstract. Secondary changes: Implement react instance methods in concrete subclasses: - **New:** BridgeReactContext: By delegating to CatalystInstance - **New:** ThemedReactContext: By delegating to inner ReactContext - **Unchanged:** BridgelessReactContext: By delegating to ReactHost ## Auxiliary changes This fixes ThemedReactContext in bridgeless mode. **Problem:** Prior, ThemedReactContext's react instance methods did not work in bridgeless mode: ThemedReactContext wasn't initialized in bridgeless mode, so all those methods had undefined behaviour. **Solution:** ThemedReactContext now implements all react instance methods, by just forwarding to the initialized ReactContext it decorates (which has an instance). NOTE: Intentionally not converting `BridgeReactContext` to Kotlin to minimize the risk of these changes. Reviewed By: cortinico Differential Revision: D56064036
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D56064036 |
Contributor
|
This pull request has been merged in fb23470. |
|
This pull request was successfully merged by @RSNara in fb23470. When will my fix make it into a release? | How to file a pick request? |
kosmydel
pushed a commit
to kosmydel/react-native
that referenced
this pull request
Jun 11, 2024
Summary: Pull Request resolved: facebook#44226 Changelog: [Android][Removed] Delete ReactContext.initializeWithInstance(). ReactContext now no longer contains legacy react instance methods. Please use BridgeReactInstance instead. Yet another attempt to land this (last one was D55964787). Copy-pasting below the amazing summary from RSNara. ## Context Prior, ReactContext used to implement bridge logic. For bridgeless mode, we created BridgelessReactContext < ReactContext ## Problem This could lead to failures: we could call bridge methods in bridgeless mode. ## Changes Primary change: - Make all the react instance methods inside ReactContext abstract. Secondary changes: Implement react instance methods in concrete subclasses: - **New:** BridgeReactContext: By delegating to CatalystInstance - **New:** ThemedReactContext: By delegating to inner ReactContext - **Unchanged:** BridgelessReactContext: By delegating to ReactHost ## Auxiliary changes This fixes ThemedReactContext in bridgeless mode. **Problem:** Prior, ThemedReactContext's react instance methods did not work in bridgeless mode: ThemedReactContext wasn't initialized in bridgeless mode, so all those methods had undefined behaviour. **Solution:** ThemedReactContext now implements all react instance methods, by just forwarding to the initialized ReactContext it decorates (which has an instance). NOTE: Intentionally not converting `BridgeReactContext` to Kotlin to minimize the risk of these changes. Reviewed By: cortinico Differential Revision: D56064036 fbshipit-source-id: 2e380bf7ee46892c5fc0044b03a929f12d122157
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Changelog: [Android][Removed] Delete ReactContext.initializeWithInstance(). ReactContext now no longer contains legacy react instance methods. Please use BridgeReactInstance instead.
Yet another attempt to land this (last one was D55964787).
Copy-pasting below the amazing summary from RSNara.
Context
Prior, ReactContext used to implement bridge logic.
For bridgeless mode, we created BridgelessReactContext < ReactContext
Problem
This could lead to failures: we could call bridge methods in bridgeless mode.
Changes
Primary change:
Secondary changes: Implement react instance methods in concrete subclasses:
Auxiliary changes
This fixes ThemedReactContext in bridgeless mode.
Problem: Prior, ThemedReactContext's react instance methods did not work in bridgeless mode: ThemedReactContext wasn't initialized in bridgeless mode, so all those methods had undefined behaviour.
Solution: ThemedReactContext now implements all react instance methods, by just forwarding to the initialized ReactContext it decorates (which has an instance).
NOTE: Intentionally not converting
BridgeReactContextto Kotlin to minimize the risk of these changes.Reviewed By: cortinico
Differential Revision: D56064036