Skip to content

Add protected field to decouple ReactFragment lifecycle events from ReactHost#46425

Closed
rozele wants to merge 3 commits into
facebook:mainfrom
rozele:export-D62449779
Closed

Add protected field to decouple ReactFragment lifecycle events from ReactHost#46425
rozele wants to merge 3 commits into
facebook:mainfrom
rozele:export-D62449779

Conversation

@rozele
Copy link
Copy Markdown
Contributor

@rozele rozele commented Sep 10, 2024

Summary:
It's entirely plausible that one would want to run a ReactFragment that does not tear down the ReactHost when it is destroyed. This adds a protected flag to disable host lifecycle events in a ReactFragment. When disabled, the onDestroy method of the ReactFragment simply stops the surface attached to it.

Changelog

[Android][Added] Flag in ReactFragment to allow unmounting a surface without destroying ReactHost.

Differential Revision: D62449779

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Sep 10, 2024
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D62449779

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D62449779

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D62449779

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D62449779

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D62449779

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D62449779

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D62449779

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D62449779

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D62449779

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D62449779

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D62449779

Summary:
ReactDelegate does not properly annotate the ReactRootView field as Nullable. This fixes that.

## Changelog

[Android][Fixed] Use appropriate Nullable attribute for ReactRootView field in ReactDelegate

Differential Revision: D62514424
Summary: It's not isomorphic for `ReactDelegate` to have a `loadApp` method to initialize a surface, but only allow unloading of a surface by calling `onHostDestroy`, which also destroys the ReactHost. This change adds an `unloadApp` method to `ReactDelegate` so it can be used in, e.g., `ReactFragment` to stop a surface without tearing down the host.

Differential Revision: D62448543
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D62449779

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D62449779

…from ReactHost (facebook#46425)

Summary:
Pull Request resolved: facebook#46425

It's entirely plausible that one would want to run a ReactFragment that does not tear down the ReactHost when it is destroyed. This adds a protected constructor that can be used to disable host lifecycle events in a ReactFragment. When disabled, the `onDestroy` method of the ReactFragment simply stops the surface attached to it using `ReactDelegate.unloadApp`.

## Changelog

[Android][Added] Flag in ReactFragment to allow unmounting a surface without destroying ReactHost.

Differential Revision: D62449779
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D62449779

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Sep 13, 2024
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request has been merged in bb3ec4d.

@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @rozele in bb3ec4d

When will my fix make it into a release? | How to file a pick request?

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. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants